Open menubar with Press rather than Release

This commit is contained in:
Alexandre Bury 2017-10-13 15:22:59 -07:00
parent 1ba00032a1
commit d6c282a799

View File

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