public abstract class UIObject extends UIEventHandler implements LXLoopTask
Modifier and Type | Field and Description |
---|---|
protected List<UIObject> |
children |
protected boolean |
hasFocus |
protected boolean |
mousePressContextMenu |
BooleanParameter |
visible |
Modifier | Constructor and Description |
---|---|
protected |
UIObject() |
Modifier and Type | Method and Description |
---|---|
protected UIObject |
addLoopTask(LXLoopTask loopTask)
Add a task to be performed on every loop of the UI engine.
|
protected void |
beginDraw(UI ui,
PGraphics pg)
Subclasses may override this method to perform operations before their
onDraw method is called or any children are drawn.
|
UIObject |
blur()
Blur this object.
|
UIObject |
bringToFront()
Brings this object to the front of its container.
|
protected UIObject |
consumeKeyEvent()
Called in a key event handler to stop this event from bubbling up the
parent container chain.
|
protected UIObject |
consumeMousePress()
Called in a mouse event handler to stop this event from bubbling up the
parent container chain.
|
protected UIObject |
consumeMouseWheelEvent()
Called in a mouse wheel handler to stop this mouse wheel event from
bubbling.
|
protected boolean |
contains(float x,
float y)
Whether the given point is contained by this object
|
protected void |
endDraw(UI ui,
PGraphics pg)
Subclasses may override this method to perform operations after their onDraw
method has been called and after all children have been drawn
|
UIObject |
focus(Event event)
Focuses on this object, giving focus to everything above
and whatever was previously focused below.
|
String |
getDescription()
Objects are encouraged to override this method providing a helpful String displayed to the user explaining
the function of this UI component.
|
UIObject |
getFocusedChild()
Gets which immediate child of this object is focused, may be null.
|
abstract float |
getHeight() |
protected LX |
getLX() |
protected UIObject |
getParent()
Subclasses may access the object that is containing this one
|
protected UI |
getUI() |
abstract float |
getWidth() |
boolean |
hasDirectFocus()
Whether this object has direct focus, meaning that no
child element is focused
|
boolean |
hasFocus()
Whether this object has focus
|
boolean |
isVisible()
Whether this object is visible.
|
protected boolean |
keyEventConsumed()
Checks whether key event was already consumed
|
void |
loop(double deltaMs)
Processes all the loop tasks in this object
|
protected boolean |
mousePressConsumed()
Checks whether the mouse event was already consumed
|
protected void |
onBlur()
Subclasses override when element loses focus
|
protected void |
onDraw(UI ui,
PGraphics pg)
Subclasses should override this method to perform their drawing functions.
|
protected void |
onFocus(Event event)
Subclasses override when element is focused
|
protected void |
onUIResize(UI ui)
Subclasses may override this method to handle resize events on the global UI.
|
protected UIObject |
removeLoopTask(LXLoopTask loopTask)
Remove a task from the UI engine
|
UIObject |
setDescription(String description) |
UIObject |
setVisible(boolean visible)
Set whether this object is visible
|
UIObject |
toggleVisible()
Toggle visible state of this component
|
onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragged, onMouseMoved, onMouseOut, onMouseOver, onMousePressed, onMouseReleased, onMouseWheel
public final BooleanParameter visible
protected boolean hasFocus
protected boolean mousePressContextMenu
protected UI getUI()
protected LX getLX()
protected UIObject addLoopTask(LXLoopTask loopTask)
loopTask
- Task to be performed on every UI frameprotected UIObject removeLoopTask(LXLoopTask loopTask)
loopTask
- Task to be removed from work listpublic final void loop(double deltaMs)
loop
in interface LXLoopTask
protected UIObject getParent()
protected boolean contains(float x, float y)
x
- x-coordinatey
- y-coordinatepublic abstract float getWidth()
public abstract float getHeight()
public String getDescription()
public boolean isVisible()
public UIObject toggleVisible()
public UIObject setVisible(boolean visible)
visible
- Whether the object is visiblepublic boolean hasFocus()
public boolean hasDirectFocus()
public UIObject getFocusedChild()
public UIObject focus(Event event)
event
- Event that triggers focuspublic UIObject blur()
public UIObject bringToFront()
protected void onUIResize(UI ui)
ui
- The UI objectprotected void beginDraw(UI ui, PGraphics pg)
ui
- UI contextpg
- Graphics contextprotected void onDraw(UI ui, PGraphics pg)
ui
- UI contextpg
- Graphics contextprotected void endDraw(UI ui, PGraphics pg)
ui
- UI contextpg
- Graphics contextprotected UIObject consumeKeyEvent()
protected boolean keyEventConsumed()
protected UIObject consumeMousePress()
protected boolean mousePressConsumed()
protected UIObject consumeMouseWheelEvent()
protected void onFocus(Event event)
event
- Event that caused focusprotected void onBlur()
LX library by Mark C. Slee. © 2012-2020