cursive/examples/src/bin/ctrl_c.rs
2020-08-04 23:24:11 -07:00

22 lines
527 B
Rust

use cursive::views;
fn main() {
let mut siv = cursive::default();
siv.clear_global_callbacks(cursive::event::Event::CtrlChar('c'));
siv.set_on_pre_event(cursive::event::Event::CtrlChar('c'), |s| {
s.add_layer(
views::Dialog::text("Do you want to quit?")
.button("Yes", |s| s.quit())
.button("No", |s| {
s.pop_layer();
}),
);
});
siv.add_layer(views::Dialog::text("Try pressing Ctrl-C!"));
siv.run();
}