Split `focus` and `unfocus` methods in `text_input`
This commit is contained in:
parent
f7d67598cb
commit
1a2cb2f35b
|
@ -693,6 +693,20 @@ impl State {
|
||||||
self.cursor
|
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.
|
/// Moves the [`Cursor`] of the [`TextInput`] to the front of the input text.
|
||||||
///
|
///
|
||||||
/// [`Cursor`]: struct.Cursor.html
|
/// [`Cursor`]: struct.Cursor.html
|
||||||
|
@ -716,12 +730,6 @@ impl State {
|
||||||
pub fn move_cursor_to(&mut self, position: usize) {
|
pub fn move_cursor_to(&mut self, position: usize) {
|
||||||
self.cursor.move_to(position);
|
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
|
// TODO: Reduce allocations
|
||||||
|
|
Loading…
Reference in New Issue