Skip to content

Commit

Permalink
Support autojump in popup SelectView (#793)
Browse files Browse the repository at this point in the history
For now, only support autojump when the popup is closed, and not inside
the menu popup itself.

Note that autojump fires the select callback, while popup mode previously
only fired the submit callback.
  • Loading branch information
bgilbert authored Jun 17, 2024
1 parent 176102a commit c173bbf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cursive-core/src/views/select_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,8 @@ impl<T: 'static + Send + Sync> SelectView<T> {
})
}

// A popup view only does one thing: open the popup on Enter.
// A popup view opens the popup on Enter, and also applies autojump if
// enabled.
fn on_event_popup(&mut self, event: Event) -> EventResult {
match event {
// TODO: add Left/Right support for quick-switch?
Expand All @@ -824,6 +825,7 @@ impl<T: 'static + Send + Sync> SelectView<T> {
position,
offset,
} if position.fits_in_rect(offset, self.last_size) => self.open_popup(),
Event::Char(c) if self.autojump => return self.on_char_event(c),
_ => EventResult::Ignored,
}
}
Expand Down

0 comments on commit c173bbf

Please sign in to comment.