mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 11:16:03 +00:00
Improved the select
example. (#501)
Now the `OnEventView.on_pre_event_inner()` calls return `Some(EventResult::Consumed(Some(Callback)))` instead of `Some(EventResult::Consumed(None))`. This follows the guidelines from documentation of methods returning a `Callback`, which say that it should be ran on the `Cursive`. While in this example this doesn't make a difference, the previous version created confusion for new users who might not realize you can pass the `Callback`s to the `Cursive` this way.
This commit is contained in:
parent
e7a813b383
commit
7b579a7d54
@ -27,12 +27,12 @@ fn main() {
|
|||||||
// Let's override the `j` and `k` keys for navigation
|
// Let's override the `j` and `k` keys for navigation
|
||||||
let select = OnEventView::new(select)
|
let select = OnEventView::new(select)
|
||||||
.on_pre_event_inner('k', |s, _| {
|
.on_pre_event_inner('k', |s, _| {
|
||||||
s.select_up(1);
|
let cb = s.select_up(1);
|
||||||
Some(EventResult::Consumed(None))
|
Some(EventResult::Consumed(Some(cb)))
|
||||||
})
|
})
|
||||||
.on_pre_event_inner('j', |s, _| {
|
.on_pre_event_inner('j', |s, _| {
|
||||||
s.select_down(1);
|
let cb = s.select_down(1);
|
||||||
Some(EventResult::Consumed(None))
|
Some(EventResult::Consumed(Some(cb)))
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut siv = cursive::default();
|
let mut siv = cursive::default();
|
||||||
|
Loading…
Reference in New Issue
Block a user