From J Wiki
Jump to navigation Jump to search
Treemap | Options | Events | Class

Treemap Events

The treemap is drawn on an isigraph control, and events for the control are typically passed to the treemap object. This can be set up automatically when the treemap is initialized. You can also create your own event handlers.

The isigraph events supported are:

mbldown mbrdown mmove paint

For example, suppose the form parent name is form and isigraph control id tm . Suppose also that the treemap locale name is tmloc, i.e. the treemap instance has been created as:

tmloc=: conew 'ptreemap'

Then event handlers are created as:

form_tm_mbldown=: mbldown__tmloc

Note that it is conventional to use the same name for the treemap 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 treemap event handler, as in:

form_tm_mbldown=: 3 : 0
NB. add pre-processing code here
NB. add post-processing code here

Signalled Events

The treemap can also pass events back to the form locale. To enable this, define a treemap event handler with a name based on the isigraph control id, followed by _tmaphandler . For example if the control id is g , then define verb g_tmaphandler .

The events signalled are:

click left click on the treemap
rclick right click on the treemap
hover mouse move to new cell on treemap

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 used to call a verb to show the current selection.

tm_tmaphandler=: 3 : 0
select. y
case. 'click' do.
  ndx=. Index__tm
  msg=. 'Selected index ',(":ndx),' Value: ',":ndx{DATA
  wdinfo 'Treemap';msg