Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close left menu with q/backspace shortcut #50

Closed
filimonov opened this issue Apr 4, 2024 · 4 comments · Fixed by #55
Closed

Close left menu with q/backspace shortcut #50

filimonov opened this issue Apr 4, 2024 · 4 comments · Fixed by #55

Comments

@filimonov
Copy link
Contributor

Since you use F1/F2/F8 keys you should also support Esc to close popups.

azat added a commit that referenced this issue Apr 4, 2024
@azat
Copy link
Owner

azat commented Apr 4, 2024

Esc is bad choice for binding to (see referenced commit), but support q/backspace for sidebar menu - make sense.

@azat azat changed the title Popup screen(s), like F1 help should react on Esc Close left menu with q/backspace shortcut Apr 4, 2024
@filimonov
Copy link
Contributor Author

filimonov commented Apr 4, 2024

And what is the exact problem? Cursive should be able to distinguish Esc and Home (and similar)

use cursive::{Cursive, event::Key};
use cursive::views::{Dialog, OnEventView};
use cursive::CursiveExt;

fn main() {
    let mut siv = Cursive::default();

    let dialog = Dialog::text("Press Esc to quit, or Home for a surprise!")
        .title("Key Event Example")
        .button("OK", |s| s.add_layer(Dialog::info("You pressed OK!")));

    let on_event_view = OnEventView::new(dialog)
        .on_event(Key::Esc, |s| s.quit())
        .on_event(Key::Home, |s| {
            s.add_layer(Dialog::info("Surprise! You pressed Home."));
        });

    siv.add_layer(on_event_view);

    siv.run();
}

azat added a commit that referenced this issue Apr 4, 2024
Apparently after switching to crossterm backend it fully functional, or
maybe that was a different terminal... For now I checked alacritty and
konsole and both are OK.

Refs: #50
azat added a commit that referenced this issue Apr 4, 2024
Apparently after switching to termion (from default ncurses) backend it
fully functional, or maybe that was a different terminal... For now I
checked alacritty and konsole and both are OK.

Refs: #50
@azat
Copy link
Owner

azat commented Apr 4, 2024

And what is the exact problem? Cursive should be able to distinguish Esc and Home (and similar)

Either the problem is gone after switching backend or terminal, so OK now - #54

@azat
Copy link
Owner

azat commented Apr 4, 2024

Though to me q looks better and more convenient, but OK to bind to both.

azat added a commit that referenced this issue Apr 4, 2024
@azat azat closed this as completed in #55 Apr 4, 2024
azat added a commit that referenced this issue Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants