pub struct TextInput<T: ClipboardProvider> { /* private fields */ }Expand description
Encapsulated state for handling keyboard input in a single or multiline text input control.
Implementations§
Source§impl<T: ClipboardProvider> TextInput<T>
impl<T: ClipboardProvider> TextInput<T>
Sourcepub fn new(
lines: Lines,
initial: DOMString,
clipboard_provider: T,
) -> TextInput<T>
pub fn new( lines: Lines, initial: DOMString, clipboard_provider: T, ) -> TextInput<T>
Instantiate a new text input control
pub fn edit_point(&self) -> RopeIndex
pub fn selection_origin(&self) -> Option<RopeIndex>
Sourcepub fn selection_origin_or_edit_point(&self) -> RopeIndex
pub fn selection_origin_or_edit_point(&self) -> RopeIndex
The selection origin, or the edit point if there is no selection. Note that the selection origin may be after the edit point, in the case of a backward selection.
pub fn selection_direction(&self) -> SelectionDirection
pub fn set_max_length(&mut self, length: Option<Utf16CodeUnitLength>)
pub fn set_min_length(&mut self, length: Option<Utf16CodeUnitLength>)
Sourcepub fn delete_char(&mut self, direction: Direction) -> bool
pub fn delete_char(&mut self, direction: Direction) -> bool
Remove a character at the current editing point
Returns true if any character was deleted
Sourcepub fn insert<S: Into<String>>(&mut self, string: S)
pub fn insert<S: Into<String>>(&mut self, string: S)
Insert a string at the current editing point or replace the selection if one exists.
Sourcepub fn selection_start(&self) -> RopeIndex
pub fn selection_start(&self) -> RopeIndex
The start of the selection (or the edit point, if there is no selection). Always less than or equal to selection_end(), regardless of the selection direction.
Sourcepub fn selection_end(&self) -> RopeIndex
pub fn selection_end(&self) -> RopeIndex
The end of the selection (or the edit point, if there is no selection). Always greater than or equal to selection_start(), regardless of the selection direction.
Sourcepub fn selection_end_offset(&self) -> Utf8CodeUnitLength
pub fn selection_end_offset(&self) -> Utf8CodeUnitLength
The byte offset of the selection_end()
Sourcepub fn replace_selection(&mut self, insert: &DOMString)
pub fn replace_selection(&mut self, insert: &DOMString)
Replace the current selection with the given DOMString. If the Rope is in
single line mode this will strip newlines, as opposed to Self::set_content,
which does not.
pub fn modify_edit_point(&mut self, amount: isize, movement: RopeMovement)
pub fn modify_selection(&mut self, amount: isize, movement: RopeMovement)
pub fn modify_selection_or_edit_point( &mut self, amount: isize, movement: RopeMovement, select: Selection, )
Sourcepub fn handle_return(&mut self) -> KeyReaction
pub fn handle_return(&mut self) -> KeyReaction
Deal with a newline input.
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all text in the input control.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Remove the current selection.
pub fn handle_keydown_aux( &mut self, key: Key, mods: Modifiers, macos: bool, ) -> KeyReaction
Sourcepub fn get_content(&self) -> DOMString
pub fn get_content(&self) -> DOMString
Get the current contents of the text input. Multiple lines are joined by \n.
Sourcepub fn set_content(&mut self, content: DOMString)
pub fn set_content(&mut self, content: DOMString)
Set the current contents of the text input. If this is control supports multiple lines, any \n encountered will be stripped and force a new logical line.
Note that when the Rope is in single line mode, this will not strip newlines.
Newline stripping only happens for incremental updates to the Rope as <input>
elements currently need to store unsanitized values while being created.
pub fn set_selection_range_utf16( &mut self, start: Utf16CodeUnitLength, end: Utf16CodeUnitLength, direction: SelectionDirection, )
pub fn set_selection_range_utf8( &mut self, start: Utf8CodeUnitLength, end: Utf8CodeUnitLength, direction: SelectionDirection, )
Trait Implementations§
Source§impl<T> MallocSizeOf for TextInput<T>where
T: MallocSizeOf + ClipboardProvider,
impl<T> MallocSizeOf for TextInput<T>where
T: MallocSizeOf + ClipboardProvider,
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl<T> Freeze for TextInput<T>where
T: Freeze,
impl<T> RefUnwindSafe for TextInput<T>where
T: RefUnwindSafe,
impl<T> Send for TextInput<T>where
T: Send,
impl<T> Sync for TextInput<T>where
T: Sync,
impl<T> Unpin for TextInput<T>where
T: Unpin,
impl<T> UnsafeUnpin for TextInput<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for TextInput<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more