pub struct TextBox {
pub handle: ControlHandle,
}
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 allow multi line input. For a single line of text, use TextInput
.
Requires the textbox
feature.
Note: Use \r\n
to input a new line not just \n
.
Builder parameters:
parent
: Required. The text box parent container.text
: The text box text.size
: The text box size.position
: The text box position.flags
: A combination of the TextBoxFlags values.ex_flags
: A combination of win32 window extended flags. Unlikeflags
, ex_flags must be used straight from winapifont
: The font used for the text box textlimit
: The maximum number of character that can be inserted in the controlreadonly
: If the textbox should allow user input or notfocus
: The control receive focus after being created
Control events:
OnTextInput
: When a TextBox value is changedMousePress(_)
: Generic mouse press events on the buttonOnMouseMove
: Generic mouse mouse eventOnMouseWheel
: Generic mouse wheel eventOnKeyPress
: Generic key press eventOnKeyRelease
: Generic key release event
use native_windows_gui as nwg;
fn build_box(tbox: &mut nwg::TextBox, window: &nwg::Window, font: &nwg::Font) {
nwg::TextBox::builder()
.text("Hello")
.font(Some(font))
.parent(window)
.build(tbox);
}
Fields§
§handle: ControlHandle
Implementations§
Source§impl TextBox
impl TextBox
pub fn builder<'a>() -> TextBoxBuilder<'a>
Sourcepub fn set_limit(&self, limit: usize)
pub fn set_limit(&self, limit: usize)
Set the number of maximum character allowed in this text input
Sourcepub fn modified(&self) -> bool
pub fn modified(&self) -> bool
Check if the content of the text input was modified after it’s creation
Sourcepub fn set_modified(&self, e: bool)
pub fn set_modified(&self, e: bool)
Manually set modified flag of the text input
Sourcepub fn selection(&self) -> Range<u32>
pub fn selection(&self) -> Range<u32>
Return the selected range of characters by the user in the text input
Sourcepub fn set_selection(&self, r: Range<u32>)
pub fn set_selection(&self, r: Range<u32>)
Return the selected range of characters by the user in the text input
Sourcepub fn len(&self) -> u32
pub fn len(&self) -> u32
Return the length of the user input in the control. Performs a newline conversion first since Windows treats “\r\n” as a single character
Sourcepub fn linecount(&self) -> i32
pub fn linecount(&self) -> i32
Return the number of lines in the multiline edit control. If the control has no text, the return value is 1.
Sourcepub fn scroll_lastline(&self)
pub fn scroll_lastline(&self)
Get the linecount and then scroll the text to the last line
Sourcepub fn readonly(&self) -> bool
pub fn readonly(&self) -> bool
Return true if the TextInput value cannot be edited. Retrurn false otherwise. A user can still copy text from a readonly TextEdit (unlike disabled)
Sourcepub fn set_readonly(&self, r: bool)
pub fn set_readonly(&self, r: bool)
Set the readonly flag of the text input A user can still copy text from a readonly TextEdit (unlike disabled)
Sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Return true if the control user can interact with the control, return false otherwise
Sourcepub fn set_enabled(&self, v: bool)
pub fn set_enabled(&self, v: bool)
Enable or disable the control
Sourcepub fn visible(&self) -> bool
pub fn visible(&self) -> bool
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))
Sourcepub fn set_visible(&self, v: bool)
pub fn set_visible(&self, v: bool)
Show or hide the control to the user
Sourcepub fn set_position(&self, x: i32, y: i32)
pub fn set_position(&self, x: i32, y: i32)
Set the position of the button in the parent window
Sourcepub fn set_text_unix2dos<'a>(&self, v: &'a str)
pub fn set_text_unix2dos<'a>(&self, v: &'a str)
Set the text in the current control, converting unix-style newlines in the input to “\r\n”
Sourcepub fn class_name(&self) -> &'static str
pub fn class_name(&self) -> &'static str
Winapi class name used during control creation
Sourcepub fn forced_flags(&self) -> u32
pub fn forced_flags(&self) -> u32
Winapi flags required by the control