summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-11-09 20:30:25 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-11-09 20:32:58 +0100
commit1a2cb2f35b452515822f4346382ae006e124e91d (patch)
treefeec4df1119b8e3d31bb9322540b6c640173410f /native
parentf7d67598cb2ce4102211f54eca45dc49eabec7cc (diff)
downloadiced-1a2cb2f35b452515822f4346382ae006e124e91d.tar.gz
iced-1a2cb2f35b452515822f4346382ae006e124e91d.tar.bz2
iced-1a2cb2f35b452515822f4346382ae006e124e91d.zip
Split `focus` and `unfocus` methods in `text_input`
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/text_input.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs
index 7af59ba1..470e92ed 100644
--- a/native/src/widget/text_input.rs
+++ b/native/src/widget/text_input.rs
@@ -693,6 +693,20 @@ impl State {
self.cursor
}
+ /// Focuses the [`TextInput`].
+ ///
+ /// [`TextInput`]: struct.TextInput.html
+ pub fn focus(&mut self) {
+ self.is_focused = true;
+ }
+
+ /// Unfocuses the [`TextInput`].
+ ///
+ /// [`TextInput`]: struct.TextInput.html
+ pub fn unfocus(&mut self) {
+ self.is_focused = false;
+ }
+
/// Moves the [`Cursor`] of the [`TextInput`] to the front of the input text.
///
/// [`Cursor`]: struct.Cursor.html
@@ -716,12 +730,6 @@ impl State {
pub fn move_cursor_to(&mut self, position: usize) {
self.cursor.move_to(position);
}
-
- /// Change the focus of the [`TextInput`] state.
- /// [`TextInput`]: struct.TextInput.html
- pub fn focus(&mut self, state: bool) {
- self.is_focused = state
- }
}
// TODO: Reduce allocations