Fix mouse interactions with the project and branch switchers (#9222)
Previously, we were considering the mouse to be "out" of a div when its hitbox wasn't hovered. However, if a parent listened for "mouse_down_out" and a child occluded the parent, the parent would always think the mouse was out even when the user clicked the child. This commit changes the definition of "mouse out" to simply mean "does not contain the point", without accounting for occlusion. Release Notes: - N/A Co-authored-by: Julia <julia@zed.dev>
This commit is contained in:
parent
d5796dc5eb
commit
409aa513d4
3 changed files with 14 additions and 10 deletions
|
@ -185,7 +185,7 @@ impl Interactivity {
|
||||||
) {
|
) {
|
||||||
self.mouse_down_listeners
|
self.mouse_down_listeners
|
||||||
.push(Box::new(move |event, phase, hitbox, cx| {
|
.push(Box::new(move |event, phase, hitbox, cx| {
|
||||||
if phase == DispatchPhase::Capture && !hitbox.is_hovered(cx) {
|
if phase == DispatchPhase::Capture && !hitbox.contains(&cx.mouse_position()) {
|
||||||
(listener)(event, cx)
|
(listener)(event, cx)
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
overlay, point, prelude::FluentBuilder, px, rems, AnchorCorner, AnyElement, Bounds,
|
div, overlay, point, prelude::FluentBuilder, px, rems, AnchorCorner, AnyElement, Bounds,
|
||||||
DismissEvent, DispatchPhase, Element, ElementContext, ElementId, HitboxId, IntoElement,
|
DismissEvent, DispatchPhase, Element, ElementContext, ElementId, HitboxId, InteractiveElement,
|
||||||
LayoutId, ManagedView, MouseDownEvent, ParentElement, Pixels, Point, View, VisualContext,
|
IntoElement, LayoutId, ManagedView, MouseDownEvent, ParentElement, Pixels, Point, View,
|
||||||
WindowContext,
|
VisualContext, WindowContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{Clickable, Selectable};
|
use crate::{Clickable, Selectable};
|
||||||
|
@ -184,7 +184,9 @@ impl<M: ManagedView> Element for PopoverMenu<M> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut element = overlay.child(menu.clone()).into_any();
|
let mut element = overlay
|
||||||
|
.child(div().occlude().child(menu.clone()))
|
||||||
|
.into_any();
|
||||||
menu_layout_id = Some(element.before_layout(cx));
|
menu_layout_id = Some(element.before_layout(cx));
|
||||||
element
|
element
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
overlay, AnchorCorner, AnyElement, Bounds, DismissEvent, DispatchPhase, Element,
|
div, overlay, AnchorCorner, AnyElement, Bounds, DismissEvent, DispatchPhase, Element,
|
||||||
ElementContext, ElementId, Hitbox, IntoElement, LayoutId, ManagedView, MouseButton,
|
ElementContext, ElementId, Hitbox, InteractiveElement, IntoElement, LayoutId, ManagedView,
|
||||||
MouseDownEvent, ParentElement, Pixels, Point, View, VisualContext, WindowContext,
|
MouseButton, MouseDownEvent, ParentElement, Pixels, Point, View, VisualContext, WindowContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct RightClickMenu<M: ManagedView> {
|
pub struct RightClickMenu<M: ManagedView> {
|
||||||
|
@ -109,7 +109,9 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
|
||||||
}
|
}
|
||||||
overlay = overlay.position(*element_state.position.borrow());
|
overlay = overlay.position(*element_state.position.borrow());
|
||||||
|
|
||||||
let mut element = overlay.child(menu.clone()).into_any();
|
let mut element = overlay
|
||||||
|
.child(div().occlude().child(menu.clone()))
|
||||||
|
.into_any();
|
||||||
menu_layout_id = Some(element.before_layout(cx));
|
menu_layout_id = Some(element.before_layout(cx));
|
||||||
element
|
element
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue