Navigation
Synopsis The model used for user-interaction.
Description The visualizations created with the Figure library can use the following generic primitives for user interaction:
  • Mouse. A figure can define its behaviour in response to mouse interaction:
    • onMouseEnter: what to do when the mouse enters the area occupied by the current figure.
    • onMouseExit: what to do when the mouse leaves the area occupied by the current figure.
    • onMouseDown: what to do when the mouse is pressed when the mouse is in the area occupied by the current figure.
    • onMouseUp: what to do when the mouse is released when the mouse is in the area occupied by the current figure.
    • onMouseMove: what to do when the mouse moves while it is already in the area occupied by the current figure.
    • onClick: what to do when the user clicks on the current figure.
  • Keyboard. A figure can define its behaviour in response to keyboard input:
    • onKeyDown: what to do when the user pressed a keyboard key when the mouse if over the current figure.
    • onKeyUp: what to do when the user releases a keyboard key when the mouse if over the current figure.
  • Interaction widget. Various interaction widgets are provided:
    • button: creates a button that can be pressed.
    • textfield: creates an area where text can be entered.
    • combo: creates a drop down list from which entries can be selected.
    • checkbox: creates an on/off check box.
    • scaleSlider: creates a slider to enter a numeric value.
The above interaction primitives all have one or more Rascal functions as argument; they act as callbacks when the interaction primitive is activated by the user.

The following properties further support interaction:
  • fswitch: replace the current figure by one from a given (static) list of figures.
  • computeFigure: replace the current figure by a dynamically created new figure.
  • timer: associate a timer with a figure.
Pitfalls
  • Interactive applications highly depend on dynamically changing property values. They frequently use the possibility to use a function, rather than a value for properties. For instance, instead of using size(10) one may use size(int(){ return n;}, where n is a variable in the scope of the function that created the figure.
  • Unfortunately we cannot show an interactive version of the above example here. Try it out in Rascal itself.
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.