mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix focus cycle on dialogs without buttons
This commit is contained in:
parent
e63e1e4916
commit
c49d18034d
@ -286,16 +286,38 @@ impl Dialog {
|
|||||||
match self.content.on_event(
|
match self.content.on_event(
|
||||||
event.relativized((self.padding + self.borders).top_left()),
|
event.relativized((self.padding + self.borders).top_left()),
|
||||||
) {
|
) {
|
||||||
EventResult::Ignored if !self.buttons.is_empty() => {
|
EventResult::Ignored => {
|
||||||
match event {
|
if !self.buttons.is_empty() {
|
||||||
Event::Key(Key::Down)
|
match event {
|
||||||
| Event::Key(Key::Tab)
|
Event::Key(Key::Down)
|
||||||
| Event::Shift(Key::Tab) => {
|
| Event::Key(Key::Tab)
|
||||||
// Default to leftmost button when going down.
|
| Event::Shift(Key::Tab) => {
|
||||||
self.focus = DialogFocus::Button(0);
|
// Default to leftmost button when going down.
|
||||||
EventResult::Consumed(None)
|
self.focus = DialogFocus::Button(0);
|
||||||
|
EventResult::Consumed(None)
|
||||||
|
}
|
||||||
|
_ => EventResult::Ignored,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match event {
|
||||||
|
Event::Shift(Key::Tab) => {
|
||||||
|
if self.content.take_focus(Direction::back()) {
|
||||||
|
self.focus = DialogFocus::Content;
|
||||||
|
EventResult::Consumed(None)
|
||||||
|
} else {
|
||||||
|
EventResult::Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::Key(Key::Tab) => {
|
||||||
|
if self.content.take_focus(Direction::front()) {
|
||||||
|
self.focus = DialogFocus::Content;
|
||||||
|
EventResult::Consumed(None)
|
||||||
|
} else {
|
||||||
|
EventResult::Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => EventResult::Ignored,
|
||||||
}
|
}
|
||||||
_ => EventResult::Ignored,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res => res,
|
res => res,
|
||||||
|
Loading…
Reference in New Issue
Block a user