Add Button::set_callback

This commit is contained in:
Alexandre Bury 2017-05-19 11:12:45 -07:00
parent 0046443bab
commit f608073bf5

View File

@ -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.