From d6c282a7998e2219c41e3be4869739c6d981f6c8 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Fri, 13 Oct 2017 15:22:59 -0700 Subject: [PATCH] Open menubar with Press rather than Release --- src/views/menubar.rs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/views/menubar.rs b/src/views/menubar.rs index bbd2228..e3e9aee 100644 --- a/src/views/menubar.rs +++ b/src/views/menubar.rs @@ -255,27 +255,7 @@ impl View for Menubar { return self.select_child(); } Event::Mouse { - event: MouseEvent::Press(_), - position, - offset, - } if position.fits(offset) && position.y == offset.y => - { - position - .checked_sub(offset) - .and_then(|pos| self.child_at(pos.x)) - .map(|child| { - self.focus = child; - }); - } - Event::Mouse { - event: MouseEvent::Press(_), - .. - } => { - self.hide(); - return EventResult::with_cb(|s| s.clear()); - } - Event::Mouse { - event: MouseEvent::Release(MouseButton::Left), + event: MouseEvent::Press(btn), position, offset, } if position.fits(offset) && position.y == offset.y => @@ -284,11 +264,19 @@ impl View for Menubar { .checked_sub(offset) .and_then(|pos| self.child_at(pos.x)) { - if self.focus == child { + self.focus = child; + if btn == MouseButton::Left { return self.select_child(); } } } + Event::Mouse { + event: MouseEvent::Press(_), + .. + } => { + self.hide(); + return EventResult::with_cb(|s| s.clear()); + } _ => return EventResult::Ignored, } EventResult::Consumed(None)