class GUIInputSelection

Inherits: GUIInputTool

Helper class for dealing with text selection for text input boxes and similar controls.

Public

Constructors

GUIInputSelection

GUIInputSelection() = default

Methods

~GUIInputSelection

~GUIInputSelection()

GetSprites

const Vector<ImageSprite *> &GetSprites() const

Returns sprites representing the currently selected areas.

GetBounds

Area2I GetBounds(u32 spriteIndex) const

Returns the bounds of the particular selection sprite, relative to the current parent GUI element.

UpdateSprite

void UpdateSprite()

Recreates the selection clip sprites.

ShowSelection

void ShowSelection(u32 anchorCaretPos)

Shows the selection using the specified anchor.

By default this will select 0 characters so you must manually move the selection using MoveSelectionToCaret() before anything is considered selected.

anchorCaretPos
Anchor position which to initially select. Anchor position determines selection area behavior when the input caret moves (determines whether left or right side of the selection will move with the caret).

ClearSelectionVisuals

void ClearSelectionVisuals()

Clears the currently active selection.

Note this does not clear the internal selection range, just the selection sprites.

MoveSelectionToCaret

void MoveSelectionToCaret(u32 caretPos)

Moves the selection to caret.

Selected area will be from the anchor provided in ShowSelection() to the caret position provided here.

IsSelectionEmpty

bool IsSelectionEmpty() const

Checks is anything selected.

SelectAll

void SelectAll()

Selects all available text.

SelectionDragStart

void SelectionDragStart(u32 caretPos)

Starts selection drag at the specified caret position.

Call SelectionDragUpdate() and SelectionDragEnd() as the drag operation progresses.

SelectionDragUpdate

void SelectionDragUpdate(u32 caretPos)

Updates selection drag at the specified caret position.

SelectionDragEnd

void SelectionDragEnd()

Stops selection drag.

GetSelectionStart

u32 GetSelectionStart() const

Gets caret index of selection start.

GetSelectionEnd

u32 GetSelectionEnd() const

Gets caret index of selection end.

Private

Methods

GetSelectionRects

Vector<Area2I> GetSelectionRects() const

Returns rectangles describing the currently selected areas.

Rectangles are relative to parent GUI element.

Fields

mSelectionStart

u32 mSelectionStart

mSelectionEnd

u32 mSelectionEnd

mSelectionAnchor

u32 mSelectionAnchor

mSelectionDragAnchor

u32 mSelectionDragAnchor

mSelectionRects

Vector<Area2I> mSelectionRects

mSprites

Vector<ImageSprite *> mSprites