Event Syntax
Syntax
! Name
! Name_*
! Name_Event
Arguments
- Name
Character. Name is the name of the event that is placed into a_dlg_button when the Change event occurs.
- Name_*
Character. Name_Event is placed into a_dlg_button when any type of ControlEvent occurs.
- Name_Event
Character. Name_Event is placed into a_dlg_button when it occurs.
Description
The event syntax gives the programmer the opportunity to write Xbasic code in the %code% section of the Xdialog that analyzes the value of a_dlg_button and responds accordingly. Refer to Trapping the Change Event for more information about Xdialog events.
Events:
Change
Character. The value of the control has changed.
Changing
Character. The value of the control is changing.
Dblclick
Character. The user double-clicks on the control.
Setfocus
Character. The control receives focus.
Killfocus
Character. The control loses focus.
Example
Note how the value of a_dlg_button is reset to NULL after being handled.
dim events[100] as C
dim a_colors[10] as C
colors = "Red,Green,Blue,Yellow,Orange,Pink"
colors = stritran(colors,",",crlf())
item_selected = "Shirt"
a_colors.initialize(colors)
a_colors.sort("ab")
ui_dlg_box("Pick a Color",<<%dlg%
Item: [.18item_selected^={Shirt,Tie,Pants,Jacket}!item_changed];
Double click on a color. |Event Name;
[.25,10color_selected^#a_colors!color_*] |[.25,10^#events];
{text=50,1:txt};
{lf};
<15Close!close> |<15Clear Events!clear>
%dlg%,<<%code%
events[events.first_empty()] = a_dlg_button
trace.writeln(a_dlg_button)
if a_dlg_button = "Clear"
events.clear()
a_dlg_button = ""
else if a_dlg_button = "Close" then
'do nothing - the dialog will close
else
a_dlg_button = ""
end if
%code%)Responding to Selected Events
To generate other events add "_*" to the event parameter of the control. To respond to a selected event (e.g. killfocus), trap the base event name (e.g. ul_cell ), then test for the extended event name (e.g. ul_cell_killfocus ).
Upper left cell |[.10ul_cell!ul_cell_*];
...
if left(a_dlg_button,7) = "ul_cell" then
if a_dlg_button = "ul_cell_killfocus" then
ul_cell = upper(ul_cell)
frow = regex_merge(ul_cell, "[A-Z]","")
fcol = asc(regex_merge(ul_cell, "[0-9]",""))-64
end if
a_dlg_button = ""
end ifSee Also