diff options
| author | 2020-06-09 19:12:52 +0200 | |
|---|---|---|
| committer | 2020-06-09 19:12:52 +0200 | |
| commit | baa1389f71e419383429eb10ac051b1aaf0a3e26 (patch) | |
| tree | 6ab0a6f0280ffc0d186aaca3540c7391389647d5 /native/src/widget | |
| parent | 49dbf2c14658cb5f2aafdbb75d826d8ba8fedc31 (diff) | |
| parent | 5260b3072ac0426489a16ab435dc9d533c5ed081 (diff) | |
| download | iced-baa1389f71e419383429eb10ac051b1aaf0a3e26.tar.gz iced-baa1389f71e419383429eb10ac051b1aaf0a3e26.tar.bz2 iced-baa1389f71e419383429eb10ac051b1aaf0a3e26.zip | |
Merge pull request #391 from bansheerubber/feature/move_cursor_to_end
Cursor Manipulation
Diffstat (limited to 'native/src/widget')
| -rw-r--r-- | native/src/widget/text_input.rs | 24 | 
1 files changed, 24 insertions, 0 deletions
| diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index e3a5355b..24085606 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -683,6 +683,30 @@ impl State {      pub fn cursor(&self) -> Cursor {          self.cursor      } + +    /// Moves the [`Cursor`] of the [`TextInput`] to the front of the input text. +    /// +    /// [`Cursor`]: struct.Cursor.html +    /// [`TextInput`]: struct.TextInput.html +    pub fn move_cursor_to_front(&mut self) { +        self.cursor.move_to(0); +    } + +    /// Moves the [`Cursor`] of the [`TextInput`] to the end of the input text. +    /// +    /// [`Cursor`]: struct.Cursor.html +    /// [`TextInput`]: struct.TextInput.html +    pub fn move_cursor_to_end(&mut self) { +        self.cursor.move_to(usize::MAX); +    } + +    /// Moves the [`Cursor`] of the [`TextInput`] to an arbitrary location. +    /// +    /// [`Cursor`]: struct.Cursor.html +    /// [`TextInput`]: struct.TextInput.html +    pub fn move_cursor_to(&mut self, position: usize) { +        self.cursor.move_to(position); +    }  }  // TODO: Reduce allocations | 
