mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-12 20:23:35 +00:00
1d54764cdb
Also update callback: use Rc instead of Box
32 lines
819 B
Rust
32 lines
819 B
Rust
extern crate cursive;
|
|
|
|
use cursive::Cursive;
|
|
use cursive::menu::MenuTree;
|
|
use cursive::view::Dialog;
|
|
use cursive::view::TextView;
|
|
use cursive::event::Key;
|
|
|
|
fn main() {
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
siv.menubar()
|
|
.add("File",
|
|
MenuTree::new()
|
|
.leaf("New", |s| s.add_layer(Dialog::info("New file!")))
|
|
.leaf("Quit", |s| s.quit()))
|
|
.add("Help",
|
|
MenuTree::new()
|
|
.leaf("Help", |s| s.add_layer(Dialog::info("Help message!")))
|
|
.leaf("About",
|
|
|s| s.add_layer(Dialog::info("Cursive v0.0.0"))));
|
|
|
|
// siv.set_autohide_menu(false);
|
|
|
|
siv.add_global_callback(Key::F(10), |s| s.select_menubar());
|
|
|
|
siv.add_layer(Dialog::new(TextView::new("Hit <F10> to show the menu!")));
|
|
|
|
siv.run();
|
|
}
|