Skip to content

Commit

Permalink
Split focus and unfocus methods in text_input
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Nov 9, 2020
1 parent f7d6759 commit 1a2cb2f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions native/src/widget/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1a2cb2f

Please sign in to comment.