Button events and functions

See also Table column heading button event function


Event function

event = func_id

The name of the function to be called when an event occurs for this button.

The function is called as follows:

func_id(event_code, button_id)

The events that cause the function to be called are:

EV_CREATE

The button has just been created.

EV_DESTROY

The button has just been destroyed.

EV_GAIN_FOCUS

The button has gained focus.

EV_LOSE_FOCUS

The button has lost focus.

EV_BUTTON_UP

The button has been moved to an UP (unselected) state.

EV_BUTTON_DOWN

The button has been moved to a DOWN (selected) state.

EV_BUTTON_CLICKED

The button has been pressed and released (push buttons). Currently this event is identical to EV_BUTTON_UP. This may change in the future.

The user has clicked down or released the right mouse button over the button.

EV_MOUSE_OVER 1

The user has moved the mouse over the button during a dialog.

EV_KEYSTROKE 1

A keystroke is typed while the button has focus.

1(1,2,3,4)

These events are not generated by default; they must always be specifically requested for the button by means of the event_enable = clause, e.g.

event_enable = EV_DEFAULT | EV_RIGHT_MOUSE_UP

New events may be added in the future. See Event functions.

When a push button is pressed, the EV_BUTTON_DOWN function is called followed by the EV_BUTTON_UP function. However, these event codes should only be used if a different action is required for each event. Normally, the correct event code to test whether a push button has been clicked is EV_BUTTON_CLICKED. Buttons which are pressed by default, e.g. when the ESC or RETURN key is pressed during a dialog, generate the EV_BUTTON_CLICKED event.

When a multi button is pressed, either the EV_BUTTON_DOWN or the EV_BUTTON_UP function is called, depending on the state to which the button is being changed. When a radio button is checked, two events are generated: EV_BUTTON_DOWN for the button being checked, and EV_BUTTON_UP for the previously checked button, which is automatically unchecked.

New events may be added in the future. See Event functions.

EXAMPLE

     +button CurrentDataDirBrowseBut at 605,30 {
          label = "&Browse..."
          event = DirBrowseButEvent
     }

     +button CurrentProgDirBrowseBut at 605,82 {
          label = "&Browse..."
          event = DirBrowseButEvent
     }

!function DirBrowseButEvent(EventCode, Object) {
!temp NewDir,,a255

     if (EventCode <> EV_BUTTON_CLICKED) then return
     NewDir = BrowseDir()
     if (NewDir = "") then return

     switch(Object) {
          case ?= CurrentDirBrowseBut:
               tmpConfig.CurrentDir = NewDir
               display CurrentDirBox
               break

          other buttons
     }

     return
}

Help function

help = func_id

The button’s help function. The function is called as follows

func_id(EV_HELP, button_id)

See Help functions.


Event enable flags

event_enable = flags

This clause is used to select the event codes which are to be enabled for the button.

Default: The standard set of events listed under the event = clause above.

EXAMPLE

event_enable = EV_DEFAULT | EV_RIGHT_MOUSE_UP

See The event_enable clause.


RELATED TOPICS

Buttons

Event functions