mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
Merge pull request #1216 from zed-industries/hover-context-menu-fix
Don't trigger hover popover action when mouse is over context menu
This commit is contained in:
commit
484e98c0bb
1 changed files with 16 additions and 1 deletions
|
@ -511,6 +511,8 @@ impl EditorElement {
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
paint.context_menu_bounds = Some(RectF::new(list_origin, context_menu.size()));
|
||||||
|
|
||||||
cx.scene.pop_stacking_context();
|
cx.scene.pop_stacking_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,6 +1344,7 @@ impl Element for EditorElement {
|
||||||
bounds,
|
bounds,
|
||||||
gutter_bounds,
|
gutter_bounds,
|
||||||
text_bounds,
|
text_bounds,
|
||||||
|
context_menu_bounds: None,
|
||||||
hover_bounds: None,
|
hover_bounds: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1424,13 +1427,24 @@ impl Element for EditorElement {
|
||||||
} => self.scroll(*position, *delta, *precise, layout, paint, cx),
|
} => self.scroll(*position, *delta, *precise, layout, paint, cx),
|
||||||
Event::KeyDown { input, .. } => self.key_down(input.as_deref(), cx),
|
Event::KeyDown { input, .. } => self.key_down(input.as_deref(), cx),
|
||||||
Event::MouseMoved { position, .. } => {
|
Event::MouseMoved { position, .. } => {
|
||||||
|
// This will be handled more correctly once https://github.com/zed-industries/zed/issues/1218 is completed
|
||||||
|
// Don't trigger hover popover if mouse is hovering over context menu
|
||||||
|
if paint
|
||||||
|
.context_menu_bounds
|
||||||
|
.map_or(false, |context_menu_bounds| {
|
||||||
|
context_menu_bounds.contains_point(*position)
|
||||||
|
})
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if paint
|
if paint
|
||||||
.hover_bounds
|
.hover_bounds
|
||||||
.map_or(false, |hover_bounds| hover_bounds.contains_point(*position))
|
.map_or(false, |hover_bounds| hover_bounds.contains_point(*position))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let point = if paint.text_bounds.contains_point(*position) {
|
let point = if paint.text_bounds.contains_point(*position) {
|
||||||
let (point, overshoot) =
|
let (point, overshoot) =
|
||||||
paint.point_for_position(&self.snapshot(cx), layout, *position);
|
paint.point_for_position(&self.snapshot(cx), layout, *position);
|
||||||
|
@ -1528,6 +1542,7 @@ pub struct PaintState {
|
||||||
bounds: RectF,
|
bounds: RectF,
|
||||||
gutter_bounds: RectF,
|
gutter_bounds: RectF,
|
||||||
text_bounds: RectF,
|
text_bounds: RectF,
|
||||||
|
context_menu_bounds: Option<RectF>,
|
||||||
hover_bounds: Option<RectF>,
|
hover_bounds: Option<RectF>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue