8.5 Interactivity specification with URN
To easily handle interactivity with axes, tables,... interactions are defined as a list of interactURN (interaction Uniform Resource Name).
Each interaction is described by an URN. The list of base interactions is accessible using menu_generation('interact'),
menu_generation('interact.iiplot'), ... URN interpretation is done by iimouse('InteractURN').
-
feplot interactivity is described in dfeplot Interact. Defaults are defined in sdtweb('menu_generation','interact.feplot').
- iiplot interactivity is described in diiplot Interact. Defaults are defined in sdtweb('menu_generation','interact.iiplot').
8.5.1 Interactivity scenario
The interaction scenario in SDT considers key, mouse and scrolling events.
For keys
-
keyDown : saves the information about the last pressed key but does nothing else to allow combinations with scroll and mouse events.
- keyUp : returns when the last matching keyDown has been consumed, otherwise builds an event tag of the form keyName.objTag where current object, current axes and current figure are tested in sequence. If the event tag matches an event registered in the sdt.KeyMap, the SdtKeyDown is emptied and associated callback is executed as detailed below.
- keyName is letter, possibly upper case with shift, that is A but not shifta. Other modifiers are control, alt.
For mouse events, one can have a key press followed by a button down or simply a button down.
-
if sdt.mode is non empty, the sdt.Click('sdt.mode') is used as evt.Click event map, examples are WMO, cursor.
- objects are matched using their objTag following the sequence CurrentObject.Tag, CurrentAxes.Tag, CurrentFigure.Tag, @ga.
- first for right click or alt+Down.objTag one opens the context menu.
- then for double click (known in MATLAB as SelectionType,open).
- if keyName+Down.objTag is matched
-
the event structure is obtained from the appropriate map. A .Cb field is executed and the call exits. A .CondCb expects the callback to return a consumed value and the callback only exits if consumed==1, thus allowing a stack of callbacks.
- one enters callback expected to deal with mouse motion until the mouse button or key is released. For example, moveCamera implements orbiting for the control+Down.feplot event.
- without a button down event match, a check of the event nature is performed. Up to 1 second is used to wait for a change to occur after the button down event: second click leading to search for Double.objTag events, button up at the same location leading to a keyName+InPlace.objTag, mouse motion leading to a rubber box opening ended by a Box.objTag event.
For scroll events
-
any key (or modifier such as shift, alt or control) must be clicked before scrolling.
- iimouse_scroll : builds an event tag of the form keyName.objTag where current object tag, current axes @OnX (within 5 pixels of x axis), @OnY (within 5 pixels of y axis), current axes tag, and current figure are tested in this order.
- If an event tag exists in the sdt.Scroll map, its callback is executed after replacing @c with the value of VerticalScrollCount.
- iimouse_zoom implements a generic handling of mouse button events. On a button down
8.5.2 Interactivity URN
Sample declarations (see more in menu_generation) are
- 'x+Down.feplot{iimouse@moveCamera,"move view x"}' describes the fact that pressing the x key and clicking in the figure will call the moveCamera subfunction of iimouse which implements figure dragging capabilities.
- Key.a{feplot(cva*),"Zoom out"}will call feplot(obj,evt,'cva*') when the lower case a key is pressed.
- 'Shift+Scroll.@OnY{iimouse@iimouse_scroll,"dolly y axis"}' calls the iimouse subfunction iimouse_scroll
- 'Box.bands{idcom@changeBand,"move bands"}' implements dragging of bands for idcom. Similar implementations are for triax and colorbar dragging.
- 'InPlace.now{ii_plp(info),"Select a pole and show"}' is used to display information on pole line markers which have the now tag.
- Normal+InPlace click with left button and no modifier.
- Shift+InPlace click with middle button (often wheel), this is called extend selection in the MATLAB documentation.
- tsCtrl+Down click with right button alt selection in the MATLAB documentation).
- Normal+Scroll scroll with no modifier.
©1991-2024 by SDTools