Implement focus_previous operation

This commit is contained in:
Héctor Ramón Jiménez 2022-08-04 03:24:44 +02:00
parent 54ad92ce91
commit 6eb3dd7e5e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 60 additions and 12 deletions

View file

@ -51,7 +51,7 @@ enum Message {
CreateTask,
FilterChanged(Filter),
TaskMessage(usize, TaskMessage),
TabPressed,
TabPressed { shift: bool },
}
impl Application for Todos {
@ -147,7 +147,13 @@ impl Application for Todos {
Command::none()
}
Message::TabPressed => widget::focus_next(),
Message::TabPressed { shift } => {
if shift {
widget::focus_previous()
} else {
widget::focus_next()
}
}
_ => Command::none(),
};
@ -251,10 +257,13 @@ impl Application for Todos {
(
Event::Keyboard(keyboard::Event::KeyPressed {
key_code: keyboard::KeyCode::Tab,
modifiers,
..
}),
event::Status::Ignored,
) => Some(Message::TabPressed),
) => Some(Message::TabPressed {
shift: modifiers.shift(),
}),
_ => None,
})
}