From 48514991d2ebc0121f76b2f6b1a559ed67c0cd2d Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 5 Mar 2018 15:24:40 -0800 Subject: [PATCH] Add Cursive::clear_global_callbacks --- src/cursive.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/cursive.rs b/src/cursive.rs index bec555d..4a0fede 100644 --- a/src/cursive.rs +++ b/src/cursive.rs @@ -419,6 +419,28 @@ impl Cursive { .push(Callback::from_fn(cb)); } + /// Removes any callback tied to the given event. + /// + /// # Examples + /// + /// ```rust,no_run + /// # extern crate cursive; + /// # use cursive::*; + /// # fn main() { + /// let mut siv = Cursive::new(); + /// + /// siv.add_global_callback('q', |s| s.quit()); + /// siv.clear_global_callbacks('q'); + /// # } + /// ``` + pub fn clear_global_callbacks(&mut self, event: E) + where + E: Into, + { + let event = event.into(); + self.global_callbacks.remove(&event); + } + /// Add a layer to the current screen. /// /// # Examples