Struct TextEdit
#[non_exhaustive]pub struct TextEdit {
pub value: String,
pub cursor: usize,
pub highlight: usize,
pub max_length: usize,
pub multiline: bool,
}Expand description
The text of a field and where its cursor and selection are, in characters
(EditBox.value, cursorPos, highlightPos, maxLength).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.value: StringThe text.
cursor: usizeThe cursor, in characters from the start.
highlight: usizeThe other end of the selection; the same as cursor when nothing is selected.
max_length: usizeThe most characters the text may have (EditBox.setMaxLength, 32 by default).
multiline: boolMultiLineEditBox: line breaks are kept and words split at any whitespace.
Implementations§
§impl TextEdit
impl TextEdit
pub fn set_value(&mut self, value: &str)
pub fn set_value(&mut self, value: &str)
EditBox.setValue: the text, cut to the maximum length, with the cursor at its end.
pub fn selected(&self) -> (usize, usize)
pub fn selected(&self) -> (usize, usize)
The selection’s start and end, in characters (kept within the text).
pub fn selected_text(&self) -> String
pub fn selected_text(&self) -> String
EditBox.getHighlighted: the selected text.
pub fn insert_text(&mut self, text: &str)
pub fn insert_text(&mut self, text: &str)
EditBox.insertText: text, filtered as StringUtil.filterText does, replaces the
selection, cut to what the maximum length leaves room for.
pub fn delete_chars(&mut self, n: isize)
pub fn delete_chars(&mut self, n: isize)
EditBox.deleteChars: n characters after the cursor (before it when negative), or the
selection when there is one.
pub fn word_position(&self, dir: isize) -> usize
pub fn word_position(&self, dir: isize) -> usize
EditBox.getWordPosition(dir) from the cursor.
pub fn word_position_from(&self, dir: isize, from: usize) -> usize
pub fn word_position_from(&self, dir: isize, from: usize) -> usize
EditBox.getWordPosition(dir, from), or MultilineTextField’s word for a multi-line
field.
pub fn set_cursor(&mut self, pos: usize, select: bool)
pub fn set_cursor(&mut self, pos: usize, select: bool)
EditBox.moveCursorTo: the cursor to pos (kept within the text), the selection’s
anchor with it unless select.
pub fn move_cursor_to_end(&mut self, select: bool)
pub fn move_cursor_to_end(&mut self, select: bool)
EditBox.moveCursorToEnd.
pub fn select_all(&mut self)
pub fn select_all(&mut self)
Ctrl+A: the cursor at the end and everything selected.