class GUIInputBox

Input box is a GUI element that accepts Unicode textual input.

It can be single or multi-line and handles various types of text manipulation.

Public

Methods

staticGetGuiTypeName

static const String &GetGuiTypeName()

Returns type name of the GUI element used for finding GUI element styles.

SetText

void SetText(const String &text)

Determines the text inside the input box.

GetText

const String &GetText() const

SetFilter

void SetFilter(std::function<bool (const String &)> filter)

Sets an optional filter that can control what is allowed to be entered into the input box.

Filter should return true if the provided string is valid and false otherwise. Set the filter to null to deactivate filtering.

staticCreate

static GUIElementType *Create(const ContentType &contents, const String &styleClass, const TInlineArray<GUIOption, 4> &options)

Creates a new GUI element.

contents
Structure describing the contents of the GUI element to create.
styleClass
Style class that will be used for determining GUI element visuals from the current style sheet. If no class is provided, default style is determined based on GUI element type.
options
Additional options that control GUI element size and position. This will override options set in the style sheet.

Fields

OnValueChanged

Event<void (const String &)> OnValueChanged

Triggered whenever input text has changed.

OnConfirm

Event<void ()> OnConfirm

Triggered when the user hits the Enter key with the input box in focus.

Internal

Constructors

GUIInputBox

GUIInputBox(PrivatelyConstruct, const GUIInputBoxContent &content, const String &styleName, const GUISizeConstraints &sizeConstraints)

Methods

CalculateUnconstrainedOptimalSize

GUILogicalSize CalculateUnconstrainedOptimalSize() const override

Calculates the optimal size for the GUI element, ignoring size constraints.

Protected

Methods

~GUIInputBox

virtual ~GUIInputBox() noexcept = default

GetStyleSheetElement

const char *GetStyleSheetElement() const override

Returns the name of the GUI element type to be used for style lookup in the style sheet.

UpdateRenderElements

void UpdateRenderElements() override

Recreates the internal render elements.

Must be called before GetRenderElementVertexAndIndexData/FillBuffer if element is dirty. Marks the element as non dirty.

DoOnMouseEvent

bool DoOnMouseEvent(const GUIMouseEvent &ev) override

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

bool DoOnTextInputEvent(const GUITextInputEvent &ev) override

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

bool DoOnCommandEvent(const GUICommandEvent &ev) override

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

bool DoOnVirtualButtonEvent(const GUIVirtualButtonEvent &ev) override

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.

GetRenderElementDepthRange

u32 GetRenderElementDepthRange() const override

Returns the range of depths that the child elements can be rendered it.

HasCustomCursor

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

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

GetContextMenu

SPtr<GUIContextMenu> GetContextMenu() const override

Returns a context menu if a GUI element has one.

Otherwise returns nullptr.

Private

Methods

InsertString

void InsertString(u32 charIndex, const String &string)

Inserts a new string into the current text at the specified index.

InsertChar

void InsertChar(u32 charIndex, u32 charCode)

Inserts a new character into the current text at the specified index.

EraseChar

void EraseChar(u32 charIndex)

Erases a single character at the specified index.

DeleteSelectedText

void DeleteSelectedText(bool internal = false)

Deletes text that is currently selected.

internal
If internal no filter will be applied after the text is deleted, and no event will be triggered either.

GetSelectedText

String GetSelectedText()

Returns currently selected text.

ShowCaret

void ShowCaret()

Shows the input caret.

You must position the caret manually after showing it.

HideCaret

void HideCaret()

Hides the input caret.

ShowSelection

void ShowSelection(u32 anchorCaretPos)

Shows selection with the specified anchor position.

You must position selection start and end before selection will actually render. Anchor position determines selection behavior as the user moves the selection with the keyboard.

ClearSelection

void ClearSelection()

Removes any active selection.

ScrollTextToCaret

void ScrollTextToCaret()

Adjusts the text offset (scroll) so that the caret is visible.

ClampScrollToBounds

void ClampScrollToBounds(const GUIPhysicalArea &unclippedTextBounds)

Clamps the text offset (scroll) so that the text fits in the provided bounds nicely with minimal white space.

GetTextOffset

GUIPhysicalPoint GetTextOffset() const

Returns offset at which to render the text.

Relative to parent widget.

CutText

void CutText()

Cuts currently selected text to clipboard.

CopyText

void CopyText()

Copies currently selected text to clipboard.

PasteText

void PasteText()

Inserts text from clipboard to current caret location.

BuildTextSpriteInformation

TextSpriteInformation BuildTextSpriteInformation() const

Builds a structure describing the text, using the current text.

Fields

mBackgroundSprite

GUIBackgroundSprite mBackgroundSprite

mTextSprite

GUIContentSprites mTextSprite

mIsMultiline

bool mIsMultiline

mTextOffset

GUIPhysicalPoint mTextOffset

mHasFocus

bool mHasFocus

mFocusGainedFrame

u64 mFocusGainedFrame

mIsMouseOver

bool mIsMouseOver

mState

mText

String mText

mCharCount

u32 mCharCount

mFilter

std::function<bool (const String &)> mFilter

mCaretShown

bool mCaretShown

mSelectionShown

bool mSelectionShown

mDragInProgress

bool mDragInProgress