class GUIInteractable

Inherits: GUIRenderable

Represents a GUI element that can be interacted with.

All interactable elements are also renderable (i.e. have a visual component).

Public

Constructors

GUIInteractable

GUIInteractable(String styleClass, const GUISizeConstraints &dimensions, GUIElementOptions options = GUIElementOptions(0))

GUIInteractable

GUIInteractable(const char *styleClass, const GUISizeConstraints &dimensions, GUIElementOptions options = GUIElementOptions(0))

Methods

~GUIInteractable

~GUIInteractable() noexcept override = default

SetFocus

virtual void SetFocus(bool enabled, bool clear = false)

Change the GUI element focus state.

enabled
Give the element focus or take it away.
clear
If true the focus will be cleared from any elements currently in focus. Otherwise the element will just be appended to the in-focus list (if enabling focus).

SetOptionFlags

void SetOptionFlags(GUIElementOptions options)

A set of flags controlling various aspects of the GUIElement.

See GUIElementOptions.

GetOptionFlags

GUIElementOptions GetOptionFlags() const

SetContextMenu

void SetContextMenu(const SPtr<GUIContextMenu> &menu)

Assigns a new context menu that will be opened when the element is right clicked.

Null is allowed in case no context menu is wanted.

SetNavigationGroup

void SetNavigationGroup(const SPtr<GUINavGroup> &navGroup)

Sets a navigation group that determines in what order are GUI elements visited when using a keyboard or gamepad to switch between the elements.

If you don't set a navigation group the elements will inherit the default navigation group from their parent GUIWidget. Also see setNavGroupIndex().

SetNavigationGroupIndex

void SetNavigationGroupIndex(i32 index)

Sets the index that determines in what order is the element visited compared to all the other elements in the nav-group.

Elements with lower index will be visited before elements with a higher index. Elements with index 0 (the default) are special and will have their visit order determines by their position compared to other elements. The applied index is tied to the nav-group, so if the nav-group changes the index will need to be re-applied.

IsInInteractionBounds

virtual bool IsInInteractionBounds(const GUIPhysicalPoint &position) const

Checks is the specified position within interactable bounds of a GUI element.

These are the bounds that will be used for hit tests for e.g. mouse cursor. By default this is the same as the absolute clipped bounds of the GUI element. Position is relative to parent GUI widget.

Destroy

void Destroy() override

Destroy the element.

Removes it from parent and widget, and queues it for deletion. Element memory will be released delayed, next frame.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Fields

OnFocusGained

Event<void ()> OnFocusGained

Triggered when the element gains focus.

OnFocusLost

Event<void ()> OnFocusLost

Triggered when the element loses focus.

Internal

Methods

DoOnMouseEvent

virtual bool DoOnMouseEvent(const GUIMouseEvent &event)

Called when a mouse event is received on any GUI element the mouse is interacting with.

Return true if you have processed the event and don't want other elements to process it.

DoOnTextInputEvent

virtual bool DoOnTextInputEvent(const GUITextInputEvent &event)

Called when some text is input and the GUI element has input focus.

Return true if you have processed the event and don't want other elements to process it.

DoOnCommandEvent

virtual bool DoOnCommandEvent(const GUICommandEvent &event)

Called when a command event is triggered.

Return true if you have processed the event and don't want other elements to process it.

DoOnVirtualButtonEvent

virtual bool DoOnVirtualButtonEvent(const GUIVirtualButtonEvent &event)

Called when a virtual button is pressed/released and the GUI element has input focus.

Return true if you have processed the event and don't want other elements to process it.

ChangeParentWidget

void ChangeParentWidget(GUIWidget *widget) override

Changes the active GUI element widget.

This allows you to move an element to a different viewport, or change element style by using a widget with a different skin. You are allowed to pass null here, but elements with no parent will be unmanaged. You will be responsible for deleting them manually, and they will not render anywhere.

NotifyStateFlagsChanged

virtual void NotifyStateFlagsChanged()

Notifies the system the state flag was added or removed.

GetNavigationGroup

SPtr<GUINavGroup> GetNavigationGroup() const

Returns the navigation group this element belongs to.

See setNavGroup().

AddStateFlags

void AddStateFlags(GUIElementStateFlags flags)

Transitions the GUI element into a new state by adding state flags.

RemoveStateFlags

void RemoveStateFlags(GUIElementStateFlags flags)

Transitions the GUI element into a new state by removing state flags.

HasCustomCursor

virtual bool HasCustomCursor(const GUIPhysicalPoint &position, CursorType &type) const

Checks if the GUI element has a custom cursor and outputs the cursor type if it does.

AcceptDragAndDrop

virtual bool AcceptDragAndDrop(const GUIPhysicalPoint &position, u32 typeId) const

Checks if the GUI element accepts a drag and drop operation of the specified type.

GetContextMenu

virtual SPtr<GUIContextMenu> GetContextMenu() const

Returns a context menu if a GUI element has one.

Otherwise returns nullptr.

GetTooltip

virtual String GetTooltip() const

Returns text to display when hovering over the element.

Returns empty string if no tooltip.

Protected

Fields

mOptionFlags

GUIElementOptions mOptionFlags

Private

Fields

mContextMenu

SPtr<GUIContextMenu> mContextMenu

mNavigationGroup

SPtr<GUINavGroup> mNavigationGroup