Implement text_input::State::focused

This commit is contained in:
Héctor Ramón Jiménez 2019-11-13 07:38:06 +01:00
parent 621e5a55b7
commit 657e513651
2 changed files with 19 additions and 0 deletions

View file

@ -11,6 +11,10 @@ where
Renderer: self::Renderer,
Message: Clone + std::fmt::Debug,
{
fn width(&self) -> Length {
self.width
}
fn layout(
&self,
renderer: &Renderer,
@ -46,6 +50,10 @@ where
}) => {
self.state.is_focused =
layout.bounds().contains(cursor_position);
if self.state.cursor_position(&self.value) == 0 {
self.state.move_cursor_to_end(&self.value);
}
}
Event::Keyboard(keyboard::Event::CharacterReceived(c))
if self.state.is_focused && !c.is_control() =>