Open menubar with Press rather than Release
@@ -255,17 +255,20 @@ impl View for Menubar {
return self.select_child();
}
Event::Mouse {
- event: MouseEvent::Press(_),
+ event: MouseEvent::Press(btn),
position,
offset,
} if position.fits(offset) && position.y == offset.y =>
{
- position
+ if let Some(child) = position
.checked_sub(offset)
.and_then(|pos| self.child_at(pos.x))
- .map(|child| {
+ {
self.focus = child;
- });
+ if btn == MouseButton::Left {
+ return self.select_child();
+ }
+ }
}
Event::Mouse {
event: MouseEvent::Press(_),
@@ -274,21 +277,6 @@ impl View for Menubar {
self.hide();
return EventResult::with_cb(|s| s.clear());
}
- Event::Mouse {
- event: MouseEvent::Release(MouseButton::Left),
- position,
- offset,
- } if position.fits(offset) && position.y == offset.y =>
- {
- if let Some(child) = position
- .checked_sub(offset)
- .and_then(|pos| self.child_at(pos.x))
- {
- if self.focus == child {
- return self.select_child();
- }
- }
- }
_ => return EventResult::Ignored,
}
EventResult::Consumed(None)
