mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add Button::set_callback
This commit is contained in:
parent
0046443bab
commit
f608073bf5
@ -37,6 +37,15 @@ impl Button {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the function to be called when the button is pressed.
|
||||
///
|
||||
/// Replaces the previous callback.
|
||||
pub fn set_callback<F>(&mut self, cb: F)
|
||||
where F: Fn(&mut Cursive) + 'static
|
||||
{
|
||||
self.callback = Callback::from_fn(cb);
|
||||
}
|
||||
|
||||
/// Disables this view.
|
||||
///
|
||||
/// A disabled view cannot be selected.
|
||||
|
Loading…
Reference in New Issue
Block a user