Merge pull request #1775 from zed-industries/drag-on-context-menu-still-click

Don't allow drag event to fall through context menu
This commit is contained in:
Julia 2022-10-18 15:24:38 -04:00 committed by GitHub
commit 826eb113e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -315,13 +315,16 @@ impl ContextMenu {
fn render_menu(&self, cx: &mut RenderContext<Self>) -> impl Element {
enum Menu {}
enum MenuItem {}
let style = cx.global::<Settings>().theme.context_menu.clone();
MouseEventHandler::<Menu>::new(0, cx, |_, cx| {
Flex::column()
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
match item {
ContextMenuItem::Item { label, action } => {
let action = action.boxed_clone();
MouseEventHandler::<MenuItem>::new(ix, cx, |state, _| {
let style =
style.item.style_for(state, Some(ix) == self.selected_index);
@ -350,6 +353,7 @@ impl ContextMenu {
cx.dispatch_action(Clicked);
cx.dispatch_any_action(action.boxed_clone());
})
.on_drag(MouseButton::Left, |_, _| {})
.boxed()
}
ContextMenuItem::Separator => Empty::new()