J6/Treeview/Events
Treeview Events
The treeview is drawn on an isigraph control, and events for the control are typically passed to the treeview object. This can be set up automatically when the treeview is initialized. You can also create your own event handlers.
The isigraph events supported are:
char mbldown mblup mmove
For example, suppose the form parent name is form and isigraph control id tv . Suppose also that the treeview locale name is tvloc, i.e. the treeview instance has been created as:
tvloc=: conew 'jtreeview'
Then event handlers are created as:
form_tv_mbldown=: mbldown__tvloc
Note that it is conventional to use the same name for the treeview locale as for the isigraph control, but in these examples, different names are used.
Event handlers that are already defined are left unchanged. For example, you could create an event handler that did some processing, then called the corresponding treeview event handler, as in:
form_tv_mbldown=: 3 : 0 NB. add pre-processing code here mbldown__tvloc'' NB. add post-processing code here )
Signalled Events
The treeview can also pass events back to the form locale. To enable this, define a treeview event handler with a name based on the isigraph control id, followed by _tvhandler . For example if the control id is g , then define verb g_treehandler .
The events signalled are:
check click in a check box key key press select node is selected toggle click in a toggle box
The verbs that call the tree handler have the same name as the event name, and call the handler with an argument of the event name. You can examine the definition of the calling verb to see the state when the handler is called.
The result of the handler must be a boolean: 0=no further execution, 1=continue normal execution, if any. Where execution normally continues, it is in a verb with the name of the event suffixed with x.
The following is a typical handler definition, in this case use to call a verb to show the current tree state.
tv_tvhandler=: 3 : 0 select. y case. 'select' do. tv_showselect'' end. 1 )