Struct native_windows_gui::TextInput[][src]

pub struct TextInput {
    pub handle: ControlHandle,
    // some fields omitted
}
Expand description

An edit control is a rectangular control window to permit the user to enter and edit text by typing on the keyboard This control only allow a single line input. For block of text, use TextBox. Winapi documentation: https://docs.microsoft.com/en-us/windows/win32/controls/about-edit-controls#text-and-input-styles

TextInput is not behind any features.

Builder parameters:

  • parent: Required. The text input parent container.
  • text: The text input text.
  • size: The text input size.
  • position: The text input position.
  • flags: A combination of the TextInputFlags values.
  • ex_flags: A combination of win32 window extended flags. Unlike flags, ex_flags must be used straight from winapi
  • font: The font used for the text input text
  • limit: The maximum number of character that can be inserted in the control
  • readonly: If the text input should allow user input or not
  • password: The password character. If set to None, the textinput is a regular control.
  • align: The alignment of the text in the text input
  • background_color: The color of the textinput top and bottom padding. This is not the white background under the text.
  • focus: The control receive focus after being created

Control events:

  • OnTextInput: When a TextInput value is changed
  • MousePress(_): Generic mouse press events on the button
  • OnMouseMove: Generic mouse mouse event
  • OnMouseWheel: Generic mouse wheel event
use native_windows_gui as nwg;
fn build_box(tbox: &mut nwg::TextInput, window: &nwg::Window, font: &nwg::Font) {
    nwg::TextInput::builder()
        .text("Hello")
        .font(Some(font))
        .parent(window)
        .build(tbox);
}

Fields

handle: ControlHandle

Implementations

Return the font of the control

Set the font of the control

Return the password character displayed by the text input. If the input is not a password, return None.

Set or Remove the password character displayed by the text input. If the input is not a password all character are re-rendered with the new character

Return the number of maximum character allowed in this text input

Set the number of maximum character allowed in this text input If limit is 0, the text length is set to 0x7FFFFFFE characters

Check if the content of the text input was modified after it’s creation

Manually set modified flag of the text input

Undo the last action by the user in the control

Return the selected range of characters by the user in the text input

Return the selected range of characters by the user in the text input

Return the length of the user input in the control. This is better than input.text().len() as it does not allocate a string in memory

Return true if the TextInput value cannot be edited. Retrurn false otherwise. A user can still copy text from a readonly TextEdit (unlike disabled)

Set the readonly flag of the text input A user can still copy text from a readonly TextEdit (unlike disabled)

Return true if the control currently has the keyboard focus

Set the keyboard focus on the button

Return true if the control user can interact with the control, return false otherwise

Enable or disable the control

Return true if the control is visible to the user. Will return true even if the control is outside of the parent client view (ex: at the position (10000, 10000))

Show or hide the control to the user

Return the size of the button in the parent window

Set the size of the button in the parent window

Return the position of the button in the parent window

Set the position of the button in the parent window

Return the text displayed in the TextInput

Set the text displayed in the TextInput

Return the placeholder text displayed in the TextInput when it is empty and does not have focus. The string returned will be as long as the user specified, however it might be longer or shorter than the actual placeholder text.

Set the placeholder text displayed in the TextInput when it is empty and does not have focus

Winapi class name used during control creation

Winapi base flags used during window creation

Winapi flags required by the control

Trait Implementations

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.