List of events supported by POOL
• Mouse move
to onmousemove :mousepos :buttons
Mouse has moved.
:mousepos
- the new position of the mouse;
:buttons
- code of the pressed buttons: 1 - left, 2 - middle, 4 - right; code is a logical sum
of flags of individual buttons if many buttons are pressed simultaneously.
• Mouse button pressed
to onmousedown :mousepos :button
Mouse button was pressed.
:mousepos
- position of the mouse;
:button
- code of the pressed button: 1 - left, 2 - middle, 4 - right.
• Mouse button released
to onmouseup :mousepos :button
Mouse button was released.
:mousepos
- position of the mouse;
:button
- code of the released button: 1 - left, 2 - middle, 4 - right.
• Mouse click
to onmouseclick :mousepos :button
Mouse button was pressed and released shortly.
:mousepos
- position of the mouse;
:button
- code of the used button: 1 - left, 2 - middle, 4 - right.
• Mouse double-click
to onmousedblclick :mousepos :button
Mouse button was pressed and released shortly twice.
:mousepos
- position of the mouse;
:button
- code of the used button: 1 - left, 2 - middle, 4 - right.
• Turtle was clicked with the mouse
to onturtleclicked :mousepos :button
Mouse button was pressed over a turtle (in a distance less than radius
from the position of a turtle).
:mousepos
- position of the mouse;
:button
- code of the used button: 1 - left, 2 - middle, 4 - right.
• Key pressed
to onkeydown :code :key :modifiers
Keyboard key was pressed.
:code
- key code (a number);
:key
- key name (a word);
:modifiers
- code of a modifier key: 1 - Shift, 2 - Alt, 4 - Control, code is a logical sum
of flags of individual buttons if many buttons are pressed simultaneously.
• Key released
to onkeyup :code :key :modifiers
Keyboard key was released.
:code
- key code (a number);
:key
- key name (a word);
:modifiers
- code of a modifier key: 1 - Shift, 2 - Alt, 4 - Control, code is a logical sum
of flags of individual buttons if many buttons are pressed simultaneously.
• Collision of two turtles
to onturtlecollided :turtle :vdir :dist
Two turtles were closer than the sum of their radius
values.
Collision event automatically raises the interaction event (oninteraction
) - first on the turtle which was hit
(:turtle
), and thein on the turtle which is executing onturtlecollided
function. Function
onturtlecollided
has to return a numerical value, which will be passed to the function oninteraction
in the argument :mag
(for example, this value can have a meaning of energy transferred in the collision).
:turtle
- a turtle which was hit in the collision;
:vdir
- unit vector of the direction to the turtle which was hit;
:dist
- distance between turtles.
• Interaction with another turtle
to oninteraction :vdir :mag :drest :turtle
Turtle was interacting with another turtle.
:vdir
- unit vector of the interaction "force" direction;
:mag
- value passed in the interaction;
:drest
- remaining distance to do if the interaction happened before the turtle has finished its
step or position changing instructions;
:turtle
- another turtle which takes part in the interaction.
• Collision with the graphics window edge
to onwallcollided :vdir :drest :wall
Turtle was closer to the edge than its radius
value.
Implementation of this function replaces the default function of the bounce
mode
.
:vdir
- unit vector of the direction to the edge;
:drest
- remaining distance to do if the collision happened before the turtle has finished its
step or position changing instructions;
:wall
- edge code: 1 - left, 2 - right, 3 - top, 4 - bottom.
• Change of the position of the edge of the graphics window
to onworldchanged :walls
Coordinate of the edge(s) has changed, e.g. window size has changed or drawing scale or center were
changed.
:walls
- array of coordinates of the window edges: {left right top bottom}.
See also:
Event and signal handling functions
Table of Content