diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-02 22:49:03 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-02 23:25:05 +0300 |
| commit | 1eb7dac77e7b62ece76c43d75a349580f936b2c6 (patch) | |
| tree | fb12b872ef6c23acc98292ef9077eb8206aa0c89 /src/app | |
| parent | 0165c333ddf0707ed4455f48048feb50bd6500ba (diff) | |
add close action button to keybind help
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/input.rs | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/app/input.rs b/src/app/input.rs index 0e6c5b62..d3a94596 100644 --- a/src/app/input.rs +++ b/src/app/input.rs @@ -1494,7 +1494,25 @@ impl AppState { && mouse.column < rect.x + rect.width && mouse.row >= rect.y && mouse.row < rect.y + rect.height; - if !inside { + let inner = Rect::new( + rect.x + 1, + rect.y + 1, + rect.width.saturating_sub(2), + rect.height.saturating_sub(2), + ); + let close = crate::ui::keybind_help_close_button_rect(Rect::new( + inner.x, + inner.y, + inner.width, + 1, + )); + if modal_action_from_buttons( + mouse.column, + mouse.row, + &[(close, ModalAction::Close)], + ) == Some(ModalAction::Close) + || !inside + { leave_modal(self); } } @@ -2506,6 +2524,29 @@ mod tests { } #[test] + fn clicking_keybind_help_close_button_closes_overlay() { + let mut app = app_for_mouse_test(); + app.state.mode = Mode::KeybindHelp; + + let rect = app.state.keybind_help_rect(); + let inner = Rect::new( + rect.x + 1, + rect.y + 1, + rect.width.saturating_sub(2), + rect.height.saturating_sub(2), + ); + let close = + crate::ui::keybind_help_close_button_rect(Rect::new(inner.x, inner.y, inner.width, 1)); + app.handle_mouse(mouse( + MouseEventKind::Down(MouseButton::Left), + close.x, + close.y, + )); + + assert_eq!(app.state.mode, Mode::Navigate); + } + + #[test] fn hovering_context_menu_updates_highlight() { let mut app = app_for_mouse_test(); app.state.context_menu = Some(ContextMenuState { |
