pub struct RichTextBox {
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
.
A rich text box is almost a superset of the normal textbox. Unlike text box, rich text box has more features and can support Component Object Model (COM) objects.
The rich text box control supports the following rich text features:
- Colored text
- Multiple fonts
- Styled text such as bold, underscore, strikeout, etc
- Bullet point list
- Paragraph with custom indent/offset
- Custom line spacing
See: https://docs.microsoft.com/en-us/windows/win32/controls/about-rich-edit-controls#rich-edit-version-41
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:
OnMouseMove
: Generic mouse mouse eventOnMouseWheel
: Generic mouse wheel eventMousePress(_)
: Generic mouse press events on the buttonOnKeyPress
: Generic key press eventOnKeyRelease
: Generic key release eventOnChar
: Generic key event. Returns achar
instead of a virtual key code
Fields§
§handle: ControlHandle
Implementations§
Source§impl RichTextBox
impl RichTextBox
pub fn builder<'a>() -> RichTextBoxBuilder<'a>
Sourcepub fn set_background_color(&self, color: [u8; 3])
pub fn set_background_color(&self, color: [u8; 3])
Sets the background color for a rich edit control. You cannot get the background color of a rich text box
Sourcepub fn set_char_format(&self, fmt: &CharFormat)
pub fn set_char_format(&self, fmt: &CharFormat)
Sets the character format of the currently selected text
Sourcepub fn char_format(&self) -> CharFormat
pub fn char_format(&self) -> CharFormat
Returns the character format of the current selected text
Sourcepub fn set_para_format(&self, fmt: &ParaFormat)
pub fn set_para_format(&self, fmt: &ParaFormat)
Sets the paragraph formatting for the current selection in a rich edit control
Sourcepub fn para_format(&self) -> ParaFormat
pub fn para_format(&self) -> ParaFormat
Returns the paragraph formatting for the current selection in a rich edit control If more than one paragraph is selected, receive the attributes of the first paragraph
Sourcepub fn set_font(&self, font: Option<&Font>)
pub fn set_font(&self, font: Option<&Font>)
Set the font of the control
It is not possible to get the base font handle of a rich label. Use char_format
instead.
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