Common Functions
Many functions are shared across multiple objects in the GUI library.
Position Functions
| Function |
Description |
move(x, y) |
Move the object to a new position. |
getPosition() |
Return the object's position, the top-left corner of its bounding box. |
setPosition(x, y) |
Move the object so the top-left corner of its bounding box sits at the given point. |
getX() |
Return the object's horizontal position. |
setX(x) |
Set the object's horizontal position. |
getY() |
Return the object's vertical position. |
setY(y) |
Set the object's vertical position. |
getCenter() |
Return the object's center point. |
setCenter(x, y) |
Move the object so its center sits at the given point. |
getCenterX() |
Return the object's horizontal center. |
setCenterX(x) |
Set the object's horizontal center. |
getCenterY() |
Return the object's vertical center. |
setCenterY(y) |
Set the object's vertical center. |
getEndpoints() |
Return the object's endpoints. |
getBoundingBox() |
Return the smallest upright box that surrounds the object. |
Size Functions
Rotation Functions
Visibility Functions
Color Functions
Hit-Testing Functions
Event Functions
Event functions are used to set callback functions that are called whenever something happens, such as the mouse moving or a key being pressed.
Mouse Events
See Mouse Events for more information on how to use mouse events.
| Function |
Description |
onMouseClick(action) |
Register a function to call when the mouse is clicked (pressed down and released) on this object. |
onMouseDown(action) |
Register a function to call when the mouse button is pressed on this object. |
onMouseUp(action) |
Register a function to call when the mouse button is released over this object. |
onMouseMove(action) |
Register a function to call when the mouse moves over this object. |
onMouseDrag(action) |
Register a function to call when the mouse is dragged over this object. |
onMouseEnter(action) |
Register a function to call when the mouse moves onto this object. |
onMouseExit(action) |
Register a function to call when the mouse moves off this object. |
Keyboard Events
See Keyboard Events for more information on how to use keyboard events.
| Function |
Description |
onKeyType(action) |
Register a function to call when a key is typed (pressed and released). |
onKeyDown(action) |
Register a function to call when a key is pressed down. |
onKeyUp(action) |
Register a function to call when a key is released. |
Display Events
See Display Events for more information on how to use display events.
Collection Functions
Collection functions are used by Displays and Groups to manage the objects they contain.