Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter EighteenDataView Integration (continued)

on_form_delete_all

Overview

The on_form_delete_all event is called when the FORM_DELETE_ALL menu function is invoked..

Syntax/Parameters

Syntax

int on_form_delete_all ( ) { ... }

Parameters

(none)

 

Return Value

An int returned as a formatted error code. The error is passed back to the caller.

Remarks

The default action for Forms View is to ignore the request (returns ERROR_FUNCTION_NOT_SUPPORTED).

To enable the ribbon or menu function, the hook on_menu_init() must return the bit FV_FORM_DELETE_ALL.

Example

An example for as data sheet employing template containing a table with a fixed read-only heading where the writable portion of table extends to the end of the sheet and first column is a padding area. In this example hook, a number of global items are already set: hView is the view’s handle; r_start is the start of table portion of the sheet; t_width is the width of the table.

                                                      /****************************************/
int on_form_delete_all() {                            /* Delete All Hook                      */
                                                      /****************************************/
    handle              hDV;                          /* Data View (Forms) Handle             */
    int                 rx, cx,                       /* Row and Column                       */
                        tab_last;                     /* Last Item (Count)                    */
    int                 rc;                           /* Return Code                          */
                                                      /*                                      */
                                                      /* ** Delete Entry                      */
                                                      /*  * Initialize                        */
    hDV = DataViewGetObject(hView);                   /* Get object for data view             */
    if (IsError(hDV)) {                               /* Something bad                        */
      MessageBox('S', "Internal Error #1");           /* Display error                        */
      return ERROR_CONDITION;                         /* Exit w/error                         */
      }                                               /* end error                            */
                                                      /*  * Get Position                      */
    rx = DataViewGetCaretRow(hDV);                    /* Get the current row position         */
    if (rx < r_start) {                               /* Should not happen                    */
      MessageBox('S', "Internal Error #2");           /* Display error                        */
      return ERROR_CONDITION;                         /* Exit w/error                         */
      }                                               /* Context error                        */
    tab_last = DataViewGetRowCount(hView);            /* Get the row count                    */
    tab_last -= r_start;                              /* Adjust for top                       */
                                                      /*  * Always Clear Top                  */
    cx = 1;                                           /* Set up column                        */
    while (cx < t_width) {                            /* Loop for all columns                 */
      DataViewCellSetText(hDV, rx, cx, "");           /* Clear the content                    */
      cx++;                                           /* Move to next                         */
      }                                               /* end clear loop                       */
                                                      /*  * Delete Row                        */
    if (tab_last > 1) {                               /* Has more than one row                */
      if (rx == r_start) { rx++; }                    /* On first line                        */
      tab_last--;                                     /* Remove the first line                */
      rx = r_start + 1;                               /* Second row                           */
      DataViewDeleteRow(hDV, rx, tab_last);           /* Delete rows                          */
      }                                               /* end has context                      */
    return ERROR_NONE;                                /* Done                                 */
    }                                                 /* end function setup                   */

Related Events

on_menu_init — Called anytime the ribbon or a menu must be prepared for display or updated.

Page revised 2024-12-13