Group
Bundle several GUI objects so they move, turn, and scale together.
Creating a Group
You can create a Group using the following functions:
Group()
Group(itemList)
| Parameter | Type | Default | Description |
|---|---|---|---|
itemList |
list[Drawable] |
[] |
The objects to start the group with. |
For example,
group = Group(itemList)
where itemList is a list of GUI objects. Moving, resizing, and rotating the group also changes the items within it accordingly.
Once created, you can add it to a Display using the Display's add() function.
Functions
Once a Group group has been created, the following functions are available:
| Function | Description |
|---|---|
group.add(item) |
Add an object to the group. |
group.addOrder(item) |
Add an object to the group on a given layer. |
group.remove(item) |
Remove an object from the group. |
group.getOrder(item) |
Return the layer an object sits on within the group. |
group.setOrder(item, order) |
Move an object to a different layer within the group. |
group.getItems() |
Return the objects currently in the group. |
Position
| Function | Description |
|---|---|
group.getPosition() |
Return the object's position, the top-left corner of its bounding box. |
group.getX() |
Return the object's horizontal position. |
group.getY() |
Return the object's vertical position. |
group.getCenter() |
Return the object's center point. |
group.getCenterX() |
Return the object's horizontal center. |
group.getCenterY() |
Return the object's vertical center. |
group.setPosition(x, y) |
Move the object so the top-left corner of its bounding box sits at the given point. |
group.setX(x) |
Set the object's horizontal position. |
group.setY(y) |
Set the object's vertical position. |
group.setCenter(x, y) |
Move the object so its center sits at the given point. |
group.setCenterX(x) |
Set the object's horizontal center. |
group.setCenterY(y) |
Set the object's vertical center. |
group.move(x, y) |
Move the object to a new position. |
Size
| Function | Description |
|---|---|
group.getSize() |
Return the object's width and height. |
group.getWidth() |
Return the object's width. |
group.getHeight() |
Return the object's height. |
group.setSize(width, height) |
Set the object's width and height. |
group.setWidth(width) |
Set the object's width. |
group.setHeight(height) |
Set the object's height. |
Rotation
| Function | Description |
|---|---|
group.getRotation() |
Return how far the object is turned. |
group.setRotation(rotation) |
Turn the object to a given angle. |
group.rotate(angle) |
Turn the object by an additional angle. |
Visibility
| Function | Description |
|---|---|
group.getVisibility() |
Return how visible the object is. |
group.setVisibility(visibility) |
Set how visible the object is. |
Information
| Function | Description |
|---|---|
group.getEndpoints() |
Return the object's four corners. |
group.getBoundingBox() |
Return the smallest upright box that surrounds the object. |
group.getGroup() |
Return the Group this object belongs to. |
group.getDisplay() |
Return the Display this object is on. |
group.setToolTipText() |
Set the hover text shown over the object. |
Hit Testing
| Function | Description |
|---|---|
group.contains(x, y) |
Report whether a point lies inside the object. |
group.intersects(other) |
Report whether this object overlaps another. |
group.encloses(other) |
Report whether this object completely contains another. |
Events
| Function | Description |
|---|---|
group.onMouseClick(action) |
Set up a function to call when the mouse is clicked on this object. |
group.onMouseDown(action) |
Set up a function to call when the mouse group is pressed on this object. |
group.onMouseUp(action) |
Set up a function to call when the mouse group is released over this object. |
group.onMouseMove(action) |
Set up a function to call when the mouse moves over this object. |
group.onMouseDrag(action) |
Set up a function to call when the mouse is dragged over this object. |
group.onMouseEnter(action) |
Set up a function to call when the mouse moves onto this object. |
group.onMouseExit(action) |
Set up a function to call when the mouse moves off this object. |
group.onKeyType(action) |
Set up a function to call when a key is typed (pressed and released). |
group.onKeyDown(action) |
Set up a function to call when a key is pressed down. |
group.onKeyUp(action) |
Set up a function to call when a key is released. |