ArcPad events

Event handling scripts are declared in ArcPad Extensible Markup Language (XML) files as attributes for an object capable of generating events. All event handler attributes use the naming convention of on[name] where [name] is the event type name.

For example, the declaration for a form button control that handles an OnClick event would appear as follows:

<BUTTON name ="ok" onclick="OKClicked" .... />

The button described above would call the script OKClicked when it's clicked.

OnValidate events handling routine in form controls

The CheckBox, ComboBox, DateTime, DomainField, Edit, ListBox, and RadioButton form controls generate an OnValidate event whenever the OK button on the form is clicked or the page containing these controls is changed. This event allows you to incorporate additional data validation for these controls.

You can access properties for the control being validated via the Object property of the ThisEvent object. For example, the current value of the control being validated can be accessed via the following VBScript code:

varCurrentValue = ThisEvent.Object.Value

The OnValidate event handling routine indicates the validity of the current control's value by setting the Result property of the ThisEvent object to either true or false. The default value is true, which indicates that the control's value is valid.

If the event handling routine sets ThisEvent.Result to false, it should also provide a descriptive message as to why the control's value is considered invalid. This is accomplished by setting the MessageText and MessageType properties of the ThisEvent object. If the event handling routine does not set ThisEvent.MessageText, a default validation error message is displayed.

The MessageType property can be used to prompt you to continue. The default value of ThisEvent.MessageType is apOKOnly, which indicates that the message will be displayed with an OK button only. When you click OK, the validation stops, and the control being validated is highlighted.

Setting the value of ThisEvent.MessageType to apOKCancel displays the OK and CANCEL buttons. Clicking OK accepts the control's value as valid and allows you to continue. Clicking CANCEL stops the validation and highlights the control. A similar handling takes places if the MessageType is set to apYesNo, in which case YES and NO buttons appear on the message box.

If ThisEvent.MessageType is set to -1, no error message is displayed, but validation stops and the control being validated is highlighted. The following VBScript fragment illustrates an event handler for the OnValidate event:

If ThisEvent.Object.Value > 10 Then 
    ThisEvent.Result = False
    ThisEvent.MessageText  = "That value seems a bit high, do you still want to use it?" 
    ThisEvent.MessageType = apYesNo + apExclamation   'YES/NO and Exclamation icon
 End if
TipTip:

A control associated with a field in a shapefile's table or ArcPad AXF layer's table will automatically perform data validation with respect to the field type. For example, an Edit control associated with a numeric field will prompt you to enter a number if you enter a non-numeric value. Similarly, a DomainField control associated with a coded value domain field will automatically present a drop-down list of valid values.

List of ArcPad events

The following table lists the events that are generated by ArcPad objects:

Object

Event

Form

OnCancel, OnKillActive, OnLoad, OnOK, OnRefresh, OnSetActive, OnUnload

Page

OnCancel, OnKillActive, OnLoad, OnSetActive, OnOK, OnUnload, OnQueryCancel, OnValidate

Control (Button)

OnClick, OnKillFocus, OnSetFocus

Control (Edit)

OnChange, OnKillFocus, OnSetFocus, OnValidate

Control (CheckBox)

OnClick, OnKillFocus, OnSetFocus, OnValidate

Control (ComboBox)

OnChange, OnCloseUp, OnDropDown, OnKillFocus, OnSelCancel, OnSelChange, OnSelOK, OnSetFocus, OnValidate

Control (DateTime)

OnChange, OnCloseUp, OnDropDown, OnKillFocus, OnSetFocus, OnValidate

Control (DomainField)

OnChange, OnCloseUp, OnDropDown, OnKillFocus, OnSelCancel, OnSelChange, OnSelOK, OnSetFocus, OnValidate

Control (ImageBox)

OnClick, OnChange

Control (ListBox)

OnKillFocus, OnSelChange, OnSelOK, OnSetFocus, OnValidate

Control (RadioButton)

OnClick, OnKillFocus, OnSetFocus, OnValidate

Control (SymbologyField)

OnKillFocus, OnSetFocus

Application

OnExEvent, OnPower, OnPreferencesChanged, OnShutDown, OnStartUp, OnTimer

Layer

OnAfterLayerDraw, OnBeforeLayerDraw, OnClose, OnFeatureAdded, OnFeatureChanged, OnFeatureDeleted, OnFeatureGeometryChanged, OnIdentify, OnOpen

Map

OnAfterDraw, OnAfterLayerDraw, OnBeforeDraw, OnBeforeLayerDraw, OnClose, OnDrawingCancelled, OnFeatureAdded, OnFeatureChanged, OnFeatureDeleted, OnFeatureGeometryChanged, OnIdentify, OnNew, OnOpen, OnPointerDown, OnPointerModeChanged, OnPointerMove, OnPointerUp, OnSave, OnSelectionChanged

Navigation

OnGoto, OnInRange

GPS

OnAverageStart, OnAverageStop, OnClose, OnExEvent, OnOpen, OnPosition, OnSentence

ToolItem

OnClick, OnPointerDown, OnPointerUp, OnPointerMove

AUX

OnClose, OnComm, OnOpen

Applet

OnLoad

Rangefinder

OnClose, OnExEvent, OnMeasurement, OnOpen


2/7/2013