mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Open menubar with Press rather than Release
This commit is contained in:
parent
1ba00032a1
commit
d6c282a799
@ -255,27 +255,7 @@ impl View for Menubar {
|
|||||||
return self.select_child();
|
return self.select_child();
|
||||||
}
|
}
|
||||||
Event::Mouse {
|
Event::Mouse {
|
||||||
event: MouseEvent::Press(_),
|
event: MouseEvent::Press(btn),
|
||||||
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),
|
|
||||||
position,
|
position,
|
||||||
offset,
|
offset,
|
||||||
} if position.fits(offset) && position.y == offset.y =>
|
} if position.fits(offset) && position.y == offset.y =>
|
||||||
@ -284,11 +264,19 @@ impl View for Menubar {
|
|||||||
.checked_sub(offset)
|
.checked_sub(offset)
|
||||||
.and_then(|pos| self.child_at(pos.x))
|
.and_then(|pos| self.child_at(pos.x))
|
||||||
{
|
{
|
||||||
if self.focus == child {
|
self.focus = child;
|
||||||
|
if btn == MouseButton::Left {
|
||||||
return self.select_child();
|
return self.select_child();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Event::Mouse {
|
||||||
|
event: MouseEvent::Press(_),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
self.hide();
|
||||||
|
return EventResult::with_cb(|s| s.clear());
|
||||||
|
}
|
||||||
_ => return EventResult::Ignored,
|
_ => return EventResult::Ignored,
|
||||||
}
|
}
|
||||||
EventResult::Consumed(None)
|
EventResult::Consumed(None)
|
||||||
|
Loading…
Reference in New Issue
Block a user