Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter EighteenDataView Integration (continued)

on_click

Overview

The on_click event handler is called when the user clicks on a cell that would not normally have edit processing such as a read-only cell.

Syntax/Parameters

Syntax

int on_click ( dword type, int row, int column ) { ... }

Parameters

type

A dword that specifies the type of click action.

row

An int that specifies the row of the cell clicked on.

column

An int that specifies the column of the cell clicked on.

Return Value

Returns an int. The return value is presently not examined by the application.

Remarks

The on_click event allows a script to process cell click actions that would normally be ignored. The type of click action gives information with respect to the click location.

  Definition   Bitwise   Description  
  Click Types           
    DV_CLICK_CELL_TYPE_MASK   0x0000000F   Mask for originating cell type  
  Cell States          
    DV_CLICK_READ_ONLY   0x00010000   Cell is in a read only state  
  Specific Type Bits           
    DV_CLICK_STATE_TRUE   0x01000000   Cell is “True” or “1” , if the cell type supports state such as a checkbox  

 

Not all click are processed through this event.

Example

In this example, the click is intercepted and ASCII style check boxes are applied in groups. The groups are defined as a toggle list and a series of check groups (one check resets the remainder in a group like a radio button).

                                                     /****************************************/
int on_click(int type, int r_x, int c_x) {           /* Unprocessed Click                    */
                                                     /****************************************/
    handle              hDV;                         /* Data View (for edit)                 */
    handle              hWP;                         /* For Fields                           */
    string              list;                        /* List of Items                        */
    string              s1;                          /* General                              */
                                                     /*                                      */
                                                     /* ** Process Check Boxes               */
                                                     /*  * Initialize                        */
    hDV = DataViewGetObject(hView);                  /* Get the object, full edit            */
    if (IsError(hDV)) { return ERROR_NONE; }         /* Just ignore on error                 */
    s1 = DataViewCellGetName(hDV, r_x, c_x);         /* Get the name                         */
                                                     /*  * Get the Checkbox Toggle           */
    if (ScanString(CHECK_TOGGLE, s1) >= 0) {         /* Any Toggle                           */
      s1 = DataViewCellGetText(hDV, r_x, c_x);       /* Get the content                      */
      if (IsTrue(s1)) {                              /* Already checked                      */
        DataViewCellSetText(hDV, r_x, c_x, "[   ]"); /* Clear                                */
        }                                            /* end checked                          */
      else {                                         /* Not checked                          */
        DataViewCellSetText(hDV, r_x, c_x, "[X]");   /* Clear                                */
        }                                            /* end not checked                      */
      return ERROR_NONE;                             /* Exit                                 */
      }                                              /* end toggle                           */
                                                     /*  * Get the Checkbox Group            */
    if (ScanString(CHECK_LIST_A, s1) >= 0) {         /*  o Forms Check Boxes                 */
      list = CHECK_LIST_A;                           /* Forms group                          */
      }                                              /* end forms                            */
    if (ScanString(CHECK_ALL_REPORTS, s1) >= 0) {    /*  o Part IV - 2                       */
      list = CHECK_ALL_REPORTS;                      /* Forms group                          */
      }                                              /* end forms                            */
    if (ScanString(CHECK_SIGNIFICANT, s1) >= 0) {    /*  o Part IV - 3                       */
      list = CHECK_SIGNIFICANT;                      /* Forms group                          */
      }                                              /* end forms                            */
    if (list == "") { return ERROR_NONE; }           /* Did not set a type, ignore           */
                                                     /*  * Clear Existing                    */
    hWP = WordParseCreate(WP_GENERAL, list);         /* Set the list                         */
    s1 = WordParseGetWord(hWP);                      /* Get the first cell name              */
                                                     /*  o Loop Through Cells                */
    while (s1 != "") {                               /* While we have items                  */
      DataViewCellSetByName(hDV, s1, "[   ]");       /* Clear                                */
      s1 = WordParseGetWord(hWP);                    /* Get the next cell name               */
      }                                              /* end clear loop                       */
    DataViewCellSetText(hDV, r_x, c_x, "[X]");       /* Set the check                        */
    return ERROR_NONE;                               /* Done                                 */
    }                                                /* end function setup                   */

The terms CHECK_TOGGLE, CHECK_LIST_A, CHECK_ALL_REPORTS and CHECK_SIGNIFICANT are defined as string literals containing a series of cell names separated by spaces. The lists are first used to determine if the incoming cell is applicable and then either toggles or operates like a radio button group in a dialog.

Related Events

Page revised 2024-12-13