To enable widget events, you must first specify events for a control from its coding properties tab.
During code generation, the event delegate gets generated into the custom folder. The event delegate is called by control.setCustomEventsDelegate(eventDelegate, eventTyle) in the configureObjectHandlersById method.
At runtime, the control’s specified events are passed to the event delegate and handled by your code. The event delegate implements IcustomEventsDelegate and has the following methods to handle a variety of events:
- Methods to onLoad event:
-
onLoad: called during loading of the control
- Methods to onDraw event:
-
paint: called when painting
drawFocus: called when drawing focus
- Methods to onClick event:
-
onFocus: called when focused
-
onUnfocus: called when unfocused
-
navigationClick: called when navigation clicked
-
navigationUnclick: called when navigation unclicked
-
navigationMovement: called when navigation moved
-
touchEvent: called when touched
Note: this event is available only to touch screen devices, make sure you define the correct preprocessor for the client project to make it work properly. Available preprocessors include VER_4_2_1, VER_4_3_0, VER_4_5_0, VER_4_6_1 and VER_4_7_0.
- Methods to onRecordSelectionChange event:
-
onRecordChange: called when scrolling through records and mainly used for table type controls (cell table, grid table, list detail). It can be used for enabling or disabling menu items, activating phone actions, expanding content of a cell, or showing cell content in a fish eye view.
- Methods to onValueChange event:
-
onValueChange: called when the value of an input control changes, and useful for linked parameters in that the values of a control change based on the selected value of another control. This is primarily used in CGI type controls.
- Methods to onOrientationChange event:
-
onOrientationChange: called when orientation changes
Note: this event is available only to touch screen devices, make sure you define the correct preprocessor for the client project to make it work properly. Available preprocessors include VER_4_2_1, VER_4_3_0, VER_4_5_0, VER_4_6_1 and VER_4_7_0.
The following sample code shows how to write widget events:
public void onOrientationChange(Object field, int controlID,
int width, int height) {
// custom code
Switch(controlID)
{
case BOBScreenCustomers.BUTTON:
Dialog.alert("button orientation changed!");
default:
return;
}
};