Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter EighteenDataView Integration (continued)

on_edit_cell_content

Overview

The on_edit_cell_content event handler is called when the user requests that the content of a cell or item be edited. This event is tied to the DATA_EDIT_CELL menu function.

Syntax/Parameters

Syntax

int on_edit_cell_content ( int row, int column ) { ... }

Parameters

row

An int that specifies the row of the cell to be edited.

column

An int that specifies the column of the cell to be edited.

Return Value

Returns an int. The script should return anything but ERROR_CANCEL (0x82000000) to override the default behavior. If the event is not canceled, the return code is passed back to the caller (presumably the menu dispatch).

Remarks

Editing a cell’s content is considered a high level process allowing a special editor or dialog box to be presented.

The on_edit_cell_content event allows a script to intercept and process the cell edit function. It is up to the script to present any dialogs and perform functions to replace a cell’s content. This event is considered a more high-level editing process than the on_edit_cell_text event. For example, the function may open an object editor and a code lookup.

The event can be canceled by returning ERROR_CANCEL.

Example

In this example, the column is examined with cv_list to determine what type of data is being edited. If a match is made, the hook reads the cell content, calls the selector routine, and then replaces the data assuming there was no error (cancel). For brevity, other cases have been omitted.

                                                       /****************************************/
int on_edit_cell_content(int r_x, int c_x) {           /* Hooked in Sh+F2                      */
                                                       /****************************************/
    string              s1, s2;                        /* General                              */
    int                 rc;                            /* Return Code                          */
                                                       /*                                      */
                                                       /* ** Edit the Cell                     */
                                                       /*  * Initialize                        */
    if (hView == NULL_HANDLE) { return ERROR_CANCEL; } /* There is a problem                   */
                                                       /*                                      */
                                                       /* ** Code Processor/Selector           */
                                                       /*  * On Code                           */
    if (cv_list[c_x][2] == 'c') {                      /* Is code                              */
                                                       /*  * Get Data                          */
      s1 = DataViewCellGetText(hView, r_x, c_x);       /* Get the current data                 */
                                                       /*  * Query                             */
      s1 = form_code_select(cd_list[c_x],              /* Perform the query                    */
                            cv_list[c_x], s1);         /*   with field data                    */
      if (IsError()) { return ERROR_CANCEL; }          /* Exit on error (cancel)               */
                                                       /*  * Replace Data                      */
      DataViewCellSetText(hView, r_x, c_x, s1);        /* Set the data back                    */
      return ERROR_NONE;                               /* Done, no default processing          */
      }                                                /* end code processor                   */
                                                       /*                                      */

        ( . . . other checks . . . )

                                                       /*                                      */
                                                       /* ** Error                             */
    MessageBox('x', "No field helper for this item");  /* Display error                        */
    return ERROR_CANCEL;                               /* Done, no default processing          */
    }                                                  /* end script entry                     */

Related Events

Page revised 2024-12-13