Navigation
Synopsis Define interactive behaviour when mouse is pressed while mouse is over figure.
Function FProperty onMouseDown(bool (int, map[KeyModifier,bool]) cb)
Description onMouseDown has a single argument: a callback cb that gets two arguments:
  • an int indicating the mouse button, 1 indicates left mouse button, 2 the middle and 3 the right. Higher numbers are used for mice with more buttons.
  • an map[KeyModifier,bool] indicating which keyboard modifiers are currently pressed. See KeyModifier.
The callback returns a bool which indicates if the event is captured. Mouse handlers are executed deepest-figure first, if the mouse press is captured then the mouse press is not propagated further so figures below (less deep than) this figure will not receive a mouse press.
Examples
import vis::KeySym;
s = "";
s2 = "";
b = box(text(str () { return s; }),
	fillColor("red"),
	onMouseDown(bool (int butnr, map[KeyModifier,bool] modifiers) {
		s = "<butnr>";
		return true;
	}));
b2 = box(vcat([
	text(str () { return s2; }),
	b],shrink(0.7)),
	fillColor("green"),
	onMouseDown(bool (int butnr, map[KeyModifier,bool] modifiers) {
		s2 = "<butnr>";
		return true;
	}));
render(b2);
onmousedown
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.