Class TextInput
Receives typed characters while it is enabled, for a text box or a chat line, and keeps the text typed.
public class TextInput : IDisposable
- Inheritance
-
TextInput
- Implements
- Inherited Members
Remarks
Dispose it when the consumer goes away. An enabled handler is held by TextInput and by the text-input refcount, so one that is only dropped keeps both for the life of the process.
Properties
IsEnabled
Whether this handler wants text input delivered to it.
public bool IsEnabled { get; set; }
Property Value
Remarks
Enabling/disabling is refcounted on Keyboard rather than calling SDL_StartTextInput/SDL_StopTextInput directly, because those are per-WINDOW state while TextInput handlers are per-consumer and several exist at once (every UI TextBox creates one, and a game can create its own for chat). Setting this to false used to stop text input for the whole window, so a TextBox losing focus permanently killed delivery to every other handler in the process.
Setting the same value twice is a no-op, so a caller that re-asserts its state can't unbalance the refcount.
Text
The text typed so far. Backspace removes the last character.
public StringBuilder Text { get; set; }
Property Value
Methods
Dispose()
Disables the handler, which stops its subscription and gives back its text-input interest. Safe to call more than once.
public void Dispose()
Events
CharEntered
Raised for each character typed while the handler is enabled. The sender is null.
public event TextInput.CharEnteredHandler CharEntered