Skip to content

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

Function Description
getSize() Return the object's width and height.
setSize(width, height) Set the object's width and height.
getWidth() Return the object's width.
setWidth(width) Set the object's width.
getHeight() Return the object's height.
setHeight(height) Set the object's height.
getRadius() Return the circle's radius.
setRadius(radius) Set the circle's radius.
getLength() Return the line's length.
setLength(length) Set the line's length.

Rotation Functions

Function Description
getRotation() Return how far the object is turned.
setRotation(rotation) Turn the object to a given angle.
rotate(angle) Turn the object by an additional angle.

Visibility Functions

Function Description
getVisibility() Return how visible the object is.
setVisibility(visibility) Set how visible the object is.

Color Functions

Function Description
getColor() Return the object's color.
setColor(color) Set the object's color.
getFill() Report whether the object is filled in.
setFill(fill) Set whether the object is filled in.
getThickness() Return the object's outline thickness.
setThickness(thickness) Set the object's outline thickness.

Information Functions

Function Description
getGroup() Return the Group this object belongs to.
getDisplay() Return the Display this object is on.
setToolTipText(text) Set the hover text shown over the object.

Hit-Testing Functions

Function Description
contains(x, y) Report whether a point lies inside the object.
intersects(other) Report whether this object overlaps another.
encloses(other) Report whether this object completely contains another.

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.

Function Description
add(item) Add an object to the collection.
addOrder(item, order) Add an object to the collection on a given layer.
remove(item) Remove an object from the collection.
removeAll() Remove every object from the collection.
getOrder(item) Return the layer an object sits on within the collection.
setOrder(item, order) Move an object to a different layer within the collection.
getItems() Return the objects currently in the collection.