mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-24 01:46:31 +00:00
Add chainable variant of on_change
This commit is contained in:
parent
8ea55a69a0
commit
fcfca86a36
@ -81,6 +81,15 @@ impl<T: 'static> RadioGroup<T> {
|
|||||||
) {
|
) {
|
||||||
self.state.borrow_mut().on_change = Some(Rc::new(on_change));
|
self.state.borrow_mut().on_change = Some(Rc::new(on_change));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a callback to be used when the selection changes.
|
||||||
|
///
|
||||||
|
/// Chainable variant.
|
||||||
|
pub fn on_change<F: 'static + Fn(&mut Cursive, &T)>(
|
||||||
|
self, on_change: F,
|
||||||
|
) -> Self {
|
||||||
|
self.with(|s| s.set_on_change(on_change))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RadioGroup<String> {
|
impl RadioGroup<String> {
|
||||||
@ -148,6 +157,7 @@ impl<T: 'static> RadioButton<T> {
|
|||||||
/// Chainable variant.
|
/// Chainable variant.
|
||||||
pub fn selected(self) -> Self {
|
pub fn selected(self) -> Self {
|
||||||
self.with(|s| {
|
self.with(|s| {
|
||||||
|
// Ignore the potential callback here
|
||||||
s.select();
|
s.select();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user