Context-menu: fix right-click edge-case
response.hovered() checks a larger rect which includes the item spacing, and it always matches the hover effect.
This commit is contained in:
parent
41f77ba7d7
commit
bbe0f6089c
2 changed files with 6 additions and 1 deletions
|
@ -329,7 +329,7 @@ impl MenuRoot {
|
|||
destroy = root.id == response.id;
|
||||
}
|
||||
if !in_old_menu {
|
||||
let in_target = response.rect.contains(pos);
|
||||
let in_target = response.hovered();
|
||||
if in_target && pointer.secondary_down() {
|
||||
return MenuResponse::Create(pos, id);
|
||||
} else if (in_target && pointer.primary_down()) || destroy {
|
||||
|
|
|
@ -176,6 +176,11 @@ impl Response {
|
|||
}
|
||||
|
||||
/// The pointer is hovering above this widget or the widget was clicked/tapped this frame.
|
||||
///
|
||||
/// Note that this is slightly different from checking `response.rect.contains(pointer_pos)`.
|
||||
/// For one, the hover rectangle is slightly larger, by half of the current item spacing
|
||||
/// (to make it easier to click things). But `hovered` also checks that no other area
|
||||
/// is covering this response rectangle.
|
||||
#[inline(always)]
|
||||
pub fn hovered(&self) -> bool {
|
||||
self.hovered
|
||||
|
|
Loading…
Reference in a new issue