2016-08-13 08:03:40 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
2016-09-29 05:45:27 +00:00
|
|
|
use cursive::Cursive;
|
|
|
|
use cursive::traits::*;
|
2017-02-07 02:18:17 +00:00
|
|
|
use cursive::views::{Dialog, SliderView};
|
2016-08-13 08:03:40 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
|
|
|
|
// Let's add a simple slider in a dialog.
|
|
|
|
// Moving the slider will update the dialog's title.
|
|
|
|
// And pressing "Enter" will show a new dialog.
|
2016-10-02 22:15:30 +00:00
|
|
|
siv.add_layer(Dialog::around(SliderView::horizontal(15)
|
2016-08-13 08:03:40 +00:00
|
|
|
.value(7)
|
|
|
|
.on_change(|s, v| {
|
|
|
|
let title = format!("[ {} ]", v);
|
2017-03-26 01:22:14 +00:00
|
|
|
s.call_on_id("dialog", |view: &mut Dialog| view.set_title(title));
|
2016-08-13 08:03:40 +00:00
|
|
|
})
|
|
|
|
.on_enter(|s, v| {
|
|
|
|
s.pop_layer();
|
|
|
|
s.add_layer(Dialog::text(format!("Lucky number {}!", v))
|
|
|
|
.button("Ok", Cursive::quit));
|
|
|
|
}))
|
2016-09-25 15:44:51 +00:00
|
|
|
.title("[ 7 ]")
|
2016-08-13 08:03:40 +00:00
|
|
|
.with_id("dialog"));
|
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|