![]() |
|
Navigation |
Synopsis Define interactive behaviour when a key is pressed.
Function FProperty onKeyDown (bool (KeySym key, map[KeyModifier,bool] modifiers) cb)
Description This property allows you to install a handler for key presses. When the mouse is over the figure (i.e. the figure has focus) and a key is pressed then the callback
cb will be called. This callback takes two arguments
Examples
import vis::KeySym; s = ""; s2 = ""; b = box(text(str () { return s; }), fillColor("red"), onKeyDown(bool (KeySym key, map[KeyModifier,bool] modifiers) { s = "<key>"; return true; })); b2 = box(vcat([ text(str () { return s2; }), b],shrink(0.7)), fillColor("green"), onKeyDown(bool (KeySym key, map[KeyModifier,bool] modifiers) { s2 = "<key>"; return true; })); render(b2); ![]()
Pitfalls Unfortunately we cannot show an interactive version here, try it out in Rascal yourself.
![]() |