Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Widgets.Controls.TextBoxWidget Class Referencesealed

Provides a single-line editable text box with keyboard caret navigation. More...

Inheritance diagram for Gondwana.Widgets.Controls.TextBoxWidget:
Gondwana.Widgets.WidgetBase Gondwana.Drawing.Direct.DirectComposite Gondwana.Drawing.Direct.IDirectCompositeChild Gondwana.Drawing.Direct.IDirectCompositeContainer Gondwana.Drawing.Direct.IDirectDrawable Gondwana.Physics.Movement.IMovable Gondwana.Drawing.IDrawable

Public Member Functions

 TextBoxWidget (RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle bounds, string text="", string? placeholder=null, string? nickname=null)
 Creates a view-level text box.
 TextBoxWidget (RenderSurfaceHostBase renderSurfaceHost, SceneLayer sceneLayer, Rectangle bounds, string text="", string? placeholder=null, string? nickname=null)
 Creates a scene-layer text box.
TextBoxWidget SetText (string? text)
 Replaces the text and moves the caret to the end.
TextBoxWidget InsertText (string? text)
 Inserts text at the current caret position.
TextBoxWidget Backspace ()
 Removes the character before the caret when possible.
TextBoxWidget Delete ()
 Removes the character at the caret when possible.
TextBoxWidget MoveCaret (int delta)
 Moves the caret by the specified character delta.
TextBoxWidget SetColors (Color background, Color border, Color focusedBorder)
 Sets the background and border colors used for normal and focused states.
TextBoxWidget SetTextColors (SKColor text, SKColor placeholder)
 Sets the text and placeholder colors.
TextBoxWidget SetTextBoxZOrder (int zOrder)
 Sets the base Z-order used by the text-box visuals.
Public Member Functions inherited from Gondwana.Widgets.WidgetBase
virtual bool HitTest (View view, Point screenPositionPx)
 Determines whether the widget can be hit at the specified screen position within the specified view.
virtual bool HitTest (Point screenPositionPx)
 Determines whether the widget can be hit at the specified screen position.
WidgetBase Show ()
 Shows the widget and registers it for input routing.
WidgetBase Hide ()
 Hides the widget and releases any routed input state.
WidgetBase Activate ()
 Activates the widget and brings it to the front of the input order.
WidgetBase Cancel ()
 Cancels the widget.
Public Member Functions inherited from Gondwana.Drawing.Direct.DirectComposite
 DirectComposite (RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, PointF anchor=default, string? nickname=null)
 Initializes a new instance of the DirectComposite class.
Vector2 GetPosition ()
 Gets the current composite anchor.
void SetPosition (Vector2 position)
 Sets the composite anchor and repositions all children from their stored offsets.
DirectComposite SetPosition (float x, float y)
 Sets the composite anchor and repositions all children from their stored offsets.
virtual DirectComposite Add (IDirectCompositeChild child, bool keepCurrentOffset=true, Vector2? explicitLocalOffsetPx=null)
 Adds a composite-compatible direct drawable as a child.
virtual DirectComposite Remove (IDirectCompositeChild child)
 Removes a child without disposing it.
virtual DirectComposite Clear ()
 Removes every child without disposing them.
DirectComposite SetLocalOffset (IDirectCompositeChild child, Vector2 newLocalOffsetPx)
 Changes one child's local offset and reapplies its position.
DirectComposite SetZOrder (int zOrder)
 Applies one Z-order to every descendant.
DirectComposite SetOpacity (float opacity)
 Applies one opacity to every descendant.
DirectComposite SetIsVisible (bool visible)
 Applies one visibility value to every descendant.
DirectComposite FadeTo (float targetOpacity, float durationSec)
 Fades every descendant to the requested opacity.
DirectComposite FadeIn (float durationSec)
 Fades every descendant to full opacity.
DirectComposite FadeOut (float durationSec)
 Fades every descendant to zero opacity.
RectangleF GetDrawLocationScreen (View view)
 Gets the union of all visible descendants as projected through a view.
void Draw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Performs no direct rendering because descendants render independently.
virtual void Update (long tick)
 Advances composite movement.
virtual void Dispose ()
 Disposes the composite and every child it owns.

Protected Member Functions

override void OnPointerClick (WidgetPointerEventArgs args)
 Called when a pointer click is dispatched to the widget.
Parameters
argsThe pointer event data.

override void OnFocusGained ()
 Called when the widget gains focus.
override void OnFocusLost ()
 Called when the widget loses focus.
override void OnKeyboardInput (WidgetKeyboardEventArgs args)
 Called when keyboard input is routed to the widget.
Parameters
argsThe keyboard event data.

Protected Member Functions inherited from Gondwana.Widgets.WidgetBase
 WidgetBase (RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, PointF anchor=default, string? nickname=null)
 Initializes a new instance of the WidgetBase class.
virtual void ProcessShown ()
 Performs processing when the widget is shown before notification callbacks are invoked.
virtual void ProcessHidden ()
 Performs processing when the widget is hidden before notification callbacks are invoked.
virtual void ProcessActivated ()
 Performs processing when the widget is activated before notification callbacks are invoked.
virtual void ProcessCancelled ()
 Performs processing when the widget is cancelled before notification callbacks are invoked.
virtual void ProcessPointerEnter (WidgetPointerEventArgs args)
 Performs processing when a pointer enters the widget before notification callbacks are invoked.
virtual void ProcessPointerLeave (WidgetPointerEventArgs args)
 Performs processing when a pointer leaves the widget before notification callbacks are invoked.
virtual void ProcessPointerDown (WidgetPointerEventArgs args)
 Performs processing when a pointer press begins on the widget before notification callbacks are invoked.
virtual void ProcessPointerMove (WidgetPointerEventArgs args)
 Performs processing when pointer movement is routed to the widget before notification callbacks are invoked.
virtual void ProcessPointerUp (WidgetPointerEventArgs args)
 Performs processing when a pointer press is released for the widget before notification callbacks are invoked.
virtual void ProcessFocusGained ()
 Performs processing when the widget gains focus before notification callbacks are invoked.
virtual void ProcessFocusLost ()
 Performs processing when the widget loses focus before notification callbacks are invoked.
virtual void ProcessKeyboardInput (WidgetKeyboardEventArgs args)
 Performs processing when keyboard input is routed to the widget before notification callbacks are invoked.
virtual bool ShouldDispatchPointerClick (WidgetPointerEventArgs args)
 Determines whether a pointer-click event should be dispatched for the specified pointer event data.
virtual void OnShown ()
 Called when the widget is shown.
virtual void OnHidden ()
 Called when the widget is hidden.
virtual void OnActivated ()
 Called when the widget is activated.
virtual void OnCancelled ()
 Called when the widget is cancelled.
virtual void OnPointerEnter (WidgetPointerEventArgs args)
 Called when a pointer enters the widget bounds.
virtual void OnPointerLeave (WidgetPointerEventArgs args)
 Called when a pointer leaves the widget bounds.
virtual void OnPointerDown (WidgetPointerEventArgs args)
 Called when a pointer press begins on the widget.
virtual void OnPointerMove (WidgetPointerEventArgs args)
 Called when pointer movement is routed to the widget.
virtual void OnPointerUp (WidgetPointerEventArgs args)
 Called when a pointer press is released for the widget.
virtual void OnMouseWheel (WidgetMouseWheelEventArgs args)
 Called when mouse-wheel input is routed to the widget.
Protected Member Functions inherited from Gondwana.Drawing.Direct.DirectComposite
virtual void OnChildAdded (IDirectCompositeChild child)
 Called after a child has been successfully added.
virtual void OnChildRemoved (IDirectCompositeChild child)
 Called after a child has been removed from the composite.

Properties

DirectRectangle Background [get]
 Gets the text-box background and border drawing.
TextBlock TextBlock [get]
 Gets the text drawing used by the text box.
string Text [get, set]
 Gets or sets the current text.
string Placeholder [get, set]
 Gets or sets placeholder text shown while the control is empty and unfocused.
int CaretIndex [get, set]
 Gets or sets the caret position in the range zero through Text length.
int? MaxLength [get, set]
 Gets or sets the maximum permitted text length. A null value means unlimited.
double InitialKeyRepeatDelaySeconds [get, set]
 Gets or sets the delay, in seconds, before a held key begins repeating. Pressed events remain immediate.
double RepeatedKeyIntervalSeconds [get, set]
 Gets or sets the minimum interval, in seconds, between repeated held-key actions after InitialKeyRepeatDelaySeconds has elapsed. Pressed events remain immediate.
bool IsReadOnly [get, set]
 Gets or sets whether user editing is disabled.
Rectangle Bounds [get]
 Gets the text-box bounds in its native coordinate space.
int SubmitKey = 13 [get, set]
 Gets or sets the key code used to submit the text. Defaults to Enter (13).
int BackspaceKey = 8 [get, set]
 Gets or sets the key code used for backspace. Defaults to 8.
int DeleteKey = 46 [get, set]
 Gets or sets the key code used for Delete. Defaults to 46.
int LeftKey = 37 [get, set]
 Gets or sets the key code used to move left. Defaults to 37.
int RightKey = 39 [get, set]
 Gets or sets the key code used to move right. Defaults to 39.
int HomeKey = 36 [get, set]
 Gets or sets the key code used to move to the beginning. Defaults to 36.
int EndKey = 35 [get, set]
 Gets or sets the key code used to move to the end. Defaults to 35.
Func< WidgetKeyboardEventArgs, char?> CharacterResolver [get, set]
 Gets or sets the function used to convert routed key events into printable characters.
Properties inherited from Gondwana.Widgets.WidgetBase
bool IsInputEnabled [get, set]
 Gets or sets a value indicating whether the widget can participate in input routing.
bool IsPointerInputEnabled [get, set]
 Gets or sets a value indicating whether the widget can receive pointer input.
bool IsKeyboardInputEnabled [get, set]
 Gets or sets a value indicating whether the widget can receive keyboard input.
bool CanReceiveFocus [get, set]
 Gets or sets a value indicating whether the widget can receive keyboard focus.
bool IsFocused [get, set]
 Gets a value indicating whether the widget currently has keyboard focus.
Properties inherited from Gondwana.Drawing.Direct.DirectComposite
Guid Id = Guid.NewGuid() [get]
 Gets the unique identifier of the composite.
string? Nickname [get]
 Gets the optional diagnostic nickname of the composite.
RenderSurfaceHostBase RenderSurfaceHost [get]
 Gets the render surface host shared by the composite and its children.
DirectDrawingMode Mode [get]
 Gets the coordinate mode shared by the composite and its children.
SceneLayer? SceneLayer [get]
 Gets the scene layer shared by all children in scene-layer mode.
View? View [get]
 Gets the view shared by all children in view mode.
ReadOnlyCollection< IDirectCompositeChild > Children [get]
 Gets the children owned by the composite.
MovementController Movement [get]
 Gets the movement controller used to move the composite anchor.
MovementSpace PositionSpace [get]
 Gets the coordinate space used by the movement controller.
bool Visible [get, set]
 Gets or sets the visibility of all descendants.
int ZOrder [get]
 Gets the composite Z-order.
Rectangle ScreenBounds [get]
 Gets the union of all visible descendants' screen-space bounds.
Rectangle WorldBounds [get]
 Gets the union of all visible descendants' world-space bounds.

Events

Action< string >? TextChanged
 Occurs when the text changes.
Action< string >? Submitted
 Occurs when the configured submit key is pressed.
Events inherited from Gondwana.Widgets.WidgetBase
Action? Shown
 Occurs when the widget is shown.
Action? Hidden
 Occurs when the widget is hidden.
Action? Activated
 Occurs when the widget is activated.
Action? Cancelled
 Occurs when the widget is cancelled.
Action< WidgetPointerEventArgs >? PointerEnter
 Occurs when a pointer enters the widget bounds.
Action< WidgetPointerEventArgs >? PointerLeave
 Occurs when a pointer leaves the widget bounds.
Action< WidgetPointerEventArgs >? PointerDown
 Occurs when a pointer button or touch press begins on the widget.
Action< WidgetPointerEventArgs >? PointerMove
 Occurs when a pointer moves while routed to the widget.
Action< WidgetPointerEventArgs >? PointerUp
 Occurs when a pointer button or touch press is released for the widget.
Action< WidgetPointerEventArgs >? PointerClick
 Occurs when a pointer press and release completes as a click on the widget.
Action< WidgetMouseWheelEventArgs >? MouseWheel
 Occurs when mouse-wheel input is routed to the widget while the pointer is over it.
Action? FocusGained
 Occurs when the widget gains keyboard focus.
Action? FocusLost
 Occurs when the widget loses keyboard focus.
Action< WidgetKeyboardEventArgs >? KeyboardInput
 Occurs when keyboard input is routed to the widget.
Events inherited from Gondwana.Drawing.Direct.DirectComposite
EventHandler< IDirectDrawable >? Disposing
 Occurs when the composite is being disposed.
Events inherited from Gondwana.Drawing.Direct.IDirectDrawable
EventHandler< IDirectDrawable >? Disposing
 Occurs when the object is being disposed.

Detailed Description

Provides a single-line editable text box with keyboard caret navigation.

Gondwana keyboard events expose host key codes. The default key bindings and character resolver use Windows virtual-key values, matching the existing widget keyboard conventions. Other hosts can replace CharacterResolver and the configurable special-key properties without subclassing the widget. Text can also be supplied directly through InsertText(string?).

Definition at line 22 of file TextBoxWidget.cs.

Constructor & Destructor Documentation

◆ TextBoxWidget() [1/2]

Gondwana.Widgets.Controls.TextBoxWidget.TextBoxWidget ( RenderSurfaceHostBase renderSurfaceHost,
View view,
Rectangle bounds,
string text = "",
string? placeholder = null,
string? nickname = null )

Creates a view-level text box.

Parameters
renderSurfaceHostThe render-surface host that owns the drawing.
viewThe view used for presentation and coordinate conversion.
boundsThe widget bounds in view-local pixels.
textThe text to display.
placeholderThe placeholder text displayed when the input is empty.
nicknameAn optional name used to identify the object.

Definition at line 60 of file TextBoxWidget.cs.

◆ TextBoxWidget() [2/2]

Gondwana.Widgets.Controls.TextBoxWidget.TextBoxWidget ( RenderSurfaceHostBase renderSurfaceHost,
SceneLayer sceneLayer,
Rectangle bounds,
string text = "",
string? placeholder = null,
string? nickname = null )

Creates a scene-layer text box.

Parameters
renderSurfaceHostThe render-surface host that owns the drawing.
sceneLayerThe scene layer that owns the content.
boundsThe widget bounds in world pixels.
textThe text to display.
placeholderThe placeholder text displayed when the input is empty.
nicknameAn optional name used to identify the object.

Definition at line 92 of file TextBoxWidget.cs.

Member Function Documentation

◆ Backspace()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.Backspace ( )

Removes the character before the caret when possible.

Returns
This instance for fluent chaining.

Definition at line 328 of file TextBoxWidget.cs.

◆ Delete()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.Delete ( )

Removes the character at the caret when possible.

Returns
This instance for fluent chaining.

Definition at line 344 of file TextBoxWidget.cs.

◆ InsertText()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.InsertText ( string? text)

Inserts text at the current caret position.

Parameters
textThe text to display.
Returns
This instance for fluent chaining.

Definition at line 298 of file TextBoxWidget.cs.

◆ MoveCaret()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.MoveCaret ( int delta)

Moves the caret by the specified character delta.

Parameters
deltaThe delta.
Returns
This instance for fluent chaining.

Definition at line 360 of file TextBoxWidget.cs.

◆ OnFocusGained()

override void Gondwana.Widgets.Controls.TextBoxWidget.OnFocusGained ( )
protectedvirtual

Called when the widget gains focus.

Reimplemented from Gondwana.Widgets.WidgetBase.

Definition at line 427 of file TextBoxWidget.cs.

◆ OnFocusLost()

override void Gondwana.Widgets.Controls.TextBoxWidget.OnFocusLost ( )
protectedvirtual

Called when the widget loses focus.

Reimplemented from Gondwana.Widgets.WidgetBase.

Definition at line 436 of file TextBoxWidget.cs.

◆ OnKeyboardInput()

override void Gondwana.Widgets.Controls.TextBoxWidget.OnKeyboardInput ( WidgetKeyboardEventArgs args)
protectedvirtual

Called when keyboard input is routed to the widget.

Parameters
argsThe keyboard event data.

Reimplemented from Gondwana.Widgets.WidgetBase.

Definition at line 446 of file TextBoxWidget.cs.

◆ OnPointerClick()

override void Gondwana.Widgets.Controls.TextBoxWidget.OnPointerClick ( WidgetPointerEventArgs args)
protectedvirtual

Called when a pointer click is dispatched to the widget.

Parameters
argsThe pointer event data.

Reimplemented from Gondwana.Widgets.WidgetBase.

Definition at line 414 of file TextBoxWidget.cs.

◆ SetColors()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.SetColors ( Color background,
Color border,
Color focusedBorder )

Sets the background and border colors used for normal and focused states.

Parameters
backgroundThe background.
borderThe border.
focusedBorderThe focused border.
Returns
This instance for fluent chaining.

Definition at line 373 of file TextBoxWidget.cs.

◆ SetText()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.SetText ( string? text)

Replaces the text and moves the caret to the end.

Parameters
textThe text to display.
Returns
This instance for fluent chaining.

Definition at line 272 of file TextBoxWidget.cs.

◆ SetTextBoxZOrder()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.SetTextBoxZOrder ( int zOrder)

Sets the base Z-order used by the text-box visuals.

Parameters
zOrderThe drawing order relative to other content.
Returns
This instance for fluent chaining.

Definition at line 406 of file TextBoxWidget.cs.

◆ SetTextColors()

TextBoxWidget Gondwana.Widgets.Controls.TextBoxWidget.SetTextColors ( SKColor text,
SKColor placeholder )

Sets the text and placeholder colors.

Parameters
textThe text to display.
placeholderThe placeholder text displayed when the input is empty.
Returns
This instance for fluent chaining.

Definition at line 393 of file TextBoxWidget.cs.

Property Documentation

◆ Background

DirectRectangle Gondwana.Widgets.Controls.TextBoxWidget.Background
get

Gets the text-box background and border drawing.

Definition at line 118 of file TextBoxWidget.cs.

◆ BackspaceKey

int Gondwana.Widgets.Controls.TextBoxWidget.BackspaceKey = 8
getset

Gets or sets the key code used for backspace. Defaults to 8.

Definition at line 231 of file TextBoxWidget.cs.

◆ Bounds

Rectangle Gondwana.Widgets.Controls.TextBoxWidget.Bounds
get

Gets the text-box bounds in its native coordinate space.

Definition at line 219 of file TextBoxWidget.cs.

◆ CaretIndex

int Gondwana.Widgets.Controls.TextBoxWidget.CaretIndex
getset

Gets or sets the caret position in the range zero through Text length.

Definition at line 150 of file TextBoxWidget.cs.

◆ CharacterResolver

Func<WidgetKeyboardEventArgs, char?> Gondwana.Widgets.Controls.TextBoxWidget.CharacterResolver
getset

Gets or sets the function used to convert routed key events into printable characters.

Definition at line 261 of file TextBoxWidget.cs.

◆ DeleteKey

int Gondwana.Widgets.Controls.TextBoxWidget.DeleteKey = 46
getset

Gets or sets the key code used for Delete. Defaults to 46.

Definition at line 236 of file TextBoxWidget.cs.

◆ EndKey

int Gondwana.Widgets.Controls.TextBoxWidget.EndKey = 35
getset

Gets or sets the key code used to move to the end. Defaults to 35.

Definition at line 256 of file TextBoxWidget.cs.

◆ HomeKey

int Gondwana.Widgets.Controls.TextBoxWidget.HomeKey = 36
getset

Gets or sets the key code used to move to the beginning. Defaults to 36.

Definition at line 251 of file TextBoxWidget.cs.

◆ InitialKeyRepeatDelaySeconds

double Gondwana.Widgets.Controls.TextBoxWidget.InitialKeyRepeatDelaySeconds
getset

Gets or sets the delay, in seconds, before a held key begins repeating. Pressed events remain immediate.

Definition at line 182 of file TextBoxWidget.cs.

◆ IsReadOnly

bool Gondwana.Widgets.Controls.TextBoxWidget.IsReadOnly
getset

Gets or sets whether user editing is disabled.

Definition at line 214 of file TextBoxWidget.cs.

◆ LeftKey

int Gondwana.Widgets.Controls.TextBoxWidget.LeftKey = 37
getset

Gets or sets the key code used to move left. Defaults to 37.

Definition at line 241 of file TextBoxWidget.cs.

◆ MaxLength

int? Gondwana.Widgets.Controls.TextBoxWidget.MaxLength
getset

Gets or sets the maximum permitted text length. A null value means unlimited.

Definition at line 163 of file TextBoxWidget.cs.

◆ Placeholder

string Gondwana.Widgets.Controls.TextBoxWidget.Placeholder
getset

Gets or sets placeholder text shown while the control is empty and unfocused.

Definition at line 137 of file TextBoxWidget.cs.

◆ RepeatedKeyIntervalSeconds

double Gondwana.Widgets.Controls.TextBoxWidget.RepeatedKeyIntervalSeconds
getset

Gets or sets the minimum interval, in seconds, between repeated held-key actions after InitialKeyRepeatDelaySeconds has elapsed. Pressed events remain immediate.

Definition at line 199 of file TextBoxWidget.cs.

◆ RightKey

int Gondwana.Widgets.Controls.TextBoxWidget.RightKey = 39
getset

Gets or sets the key code used to move right. Defaults to 39.

Definition at line 246 of file TextBoxWidget.cs.

◆ SubmitKey

int Gondwana.Widgets.Controls.TextBoxWidget.SubmitKey = 13
getset

Gets or sets the key code used to submit the text. Defaults to Enter (13).

Definition at line 226 of file TextBoxWidget.cs.

◆ Text

string Gondwana.Widgets.Controls.TextBoxWidget.Text
getset

Gets or sets the current text.

Definition at line 128 of file TextBoxWidget.cs.

◆ TextBlock

TextBlock Gondwana.Widgets.Controls.TextBoxWidget.TextBlock
get

Gets the text drawing used by the text box.

Definition at line 123 of file TextBoxWidget.cs.

Event Documentation

◆ Submitted

Action<string>? Gondwana.Widgets.Controls.TextBoxWidget.Submitted

Occurs when the configured submit key is pressed.

Definition at line 49 of file TextBoxWidget.cs.

◆ TextChanged

Action<string>? Gondwana.Widgets.Controls.TextBoxWidget.TextChanged

Occurs when the text changes.

Definition at line 44 of file TextBoxWidget.cs.