Repository navigation
Widgets TextBoxWidget
TextBoxWidget is a single-line editable text control with a visible caret, placeholder text, keyboard navigation, deletion, submit behavior, and a small widget-local held-key repeat throttle.
Use it for player names, chat-entry fields, search/filter text, seed values, server addresses, and other short text input.
These examples assume you already have a
RenderSurfaceHostBasenamedhostand, where appropriate, aViewnamedview, aSceneLayernamedsceneLayer, or aSpritenamedsprite.
using System.Drawing;
using Gondwana.Widgets.Controls;
var playerName = new TextBoxWidget(
host,
view,
new Rectangle(40, 40, 280, 34),
placeholder: "Player name");
playerName.MaxLength = 24;
playerName.TextChanged += text =>
{
settings.PlayerName = text;
};
playerName.Submitted += text =>
{
BeginGame(text);
};By default, Enter submits the current text.
playerName.SetText("Ada");
playerName.CaretIndex = 1;
playerName.InsertText("l");
playerName.Backspace();
playerName.Delete();
playerName.MoveCaret(1);playerName.IsReadOnly = true;The text remains visible and focusable, but user editing is disabled.
playerName.Placeholder = "Enter your name";
playerName.MaxLength = 20;The default printable-character resolver and special key values follow Windows virtual-key conventions. Other hosts can replace the resolver and key codes without subclassing:
playerName.CharacterResolver = args =>
{
// Translate the host key event into a printable character.
return ResolveCharacterForThisHost(args);
};
playerName.SubmitKey = mySubmitKey;
playerName.BackspaceKey = myBackspaceKey;For Blazor hosts, use the built-in helper rather than maintaining that mapping manually:
BlazorTextBoxInput.Configure(playerName);This applies the BlazorKey special-key values and printable-character resolver while leaving TextBoxWidget itself platform-neutral.
Setting CharacterResolver to null suppresses printable character conversion.
| Member | Purpose |
|---|---|
Text |
Current single-line value. |
Placeholder |
Text shown when empty and unfocused. |
CaretIndex |
Current insertion position. |
MaxLength |
Optional maximum length. |
IsReadOnly |
Disables user editing. |
RepeatedKeyIntervalSeconds |
Minimum interval between processed held-key repeats; pressed keys remain immediate. |
TextChanged |
Raised when text changes. |
Submitted |
Raised when the submit key is pressed. |
SetColors() |
Sets background, normal border, and focused border colors. |
SetTextColors() |
Sets text and placeholder colors. |
TextBoxWidget supports both View and SceneLayer placement.
- Home
- Make Your First Game in 30 Minutes
- Engine Architecture Overview
- Game Hosts and Application Startup
- Gondwana Engine Lifecycle
- Gondwana CLI Cheatsheet
- Using Gondwana with ChatGPT and Codex
Core Concepts
Systems
Rendering
Widgets
-
Controls
-
Dialogs
- AboutBox
- ConversationBox
- DialogBox — base class for custom dialogs
-
Hud
-
Layout
-
Menus
-
Overlays