summaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-11-09 20:49:42 +0100
committerLibravatar GitHub <noreply@github.com>2020-11-09 20:49:42 +0100
commitd0402d072d3f4e128c55fc0a6184c5f7c712bb20 (patch)
treefeec4df1119b8e3d31bb9322540b6c640173410f /native/src
parentda1a3eed1e6e67c2c0507e3b939e4aacdc06c19a (diff)
parent1a2cb2f35b452515822f4346382ae006e124e91d (diff)
downloadiced-d0402d072d3f4e128c55fc0a6184c5f7c712bb20.tar.gz
iced-d0402d072d3f4e128c55fc0a6184c5f7c712bb20.tar.bz2
iced-d0402d072d3f4e128c55fc0a6184c5f7c712bb20.zip
Merge pull request #598 from oknozor/input-text-focus
Add textinput focus method
Diffstat (limited to 'native/src')
-rw-r--r--native/src/widget/text_input.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs
index 64182f2d..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