TextBox

A native text entry field built on the Win32 EDIT control.

Constructors

this
this(Widget parent, string initialText, TextBoxStyle style)

Create a text box.

Members

Functions

appendText
void appendText(string text)

Append text at the end of the control, moving the caret there first.

getPreferredSize
Size getPreferredSize()

Preferred size: compact for single-line, taller for multi-line.

getSelectionRange
int[2] getSelectionRange()

Return the current selection as [start, end] character offsets.

processCommand
bool processCommand(ushort notificationCode)

Fire onTextChanged on EN_CHANGE notifications.

processSubclassed
bool processSubclassed(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result)

Intercept WM_KEYDOWN to surface onKeyDown and allow suppression.

selectAll
void selectAll()

Select all the text in the control.

setReadOnly
void setReadOnly(bool ro)

Toggle the read-only state of the control.

Variables

onKeyDown
Event!(KeyEventArgs) onKeyDown;

Fired on a key press while the control has focus.

onTextChanged
Event!(string) onTextChanged;

Fired when the text changes (EN_CHANGE); carries the new text.

Inherited Members

From Control

controlId
int controlId()

The control's command identifier (the hMenu child id at creation).

setText
void setText(string text)

Set the control's text.

getText
string getText()

Get the control's text.

setFont
void setFont(HFONT font)

Assign a font to the control and request a repaint.

getPreferredSize
Size getPreferredSize()

A reasonable default preferred size; override per control type.

processCommand
bool processCommand(ushort notificationCode)

Handle a WM_COMMAND notification routed from the parent.

processNotify
bool processNotify(NMHDR* header)

Handle a WM_NOTIFY notification routed from the parent. Return true if it was handled. The default does nothing.

subclass
void subclass()

Install a subclass window procedure so the control can intercept its own messages (for example, swallowing the Enter key in a text field). Idempotent. Subclasses override processSubclassed to do the work.

processSubclassed
bool processSubclassed(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result)

Intercept a message while subclassed. Set result and return true to consume the message; return false to let default processing continue.

Meta