Implement MessageMapper for Listener
@@ -368,6 +368,25 @@ impl<Ms> Listener<Ms> {
}
}
+
+impl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for Listener<Ms> {
+ type SelfWithOtherMs = Listener<OtherMs>;
+ fn map_message(self, f: fn(Ms) -> OtherMs) -> Self::SelfWithOtherMs {
+ Listener {
+ trigger: self.trigger,
+ handler: self.handler.map(|mut eh| {
+ Box::new(move |event| {
+ let m = (*eh)(event);
+ (f)(m)
+ }) as EventHandler<OtherMs>
+ }),
+ closure: self.closure,
+ control_val: self.control_val,
+ control_checked: self.control_checked,
+ }
+ }
+}
+
impl<Ms: 'static> Listener<Ms> {
/// Converts the message type of the listener.
fn map_message<OtherMs, F>(self, f: F) -> Listener<OtherMs>
