Don't allow drag event to fall through context menu
This commit is contained in:
parent
4ef69c8361
commit
2661a9cc98
1 changed files with 4 additions and 0 deletions
|
@ -315,13 +315,16 @@ impl ContextMenu {
|
||||||
fn render_menu(&self, cx: &mut RenderContext<Self>) -> impl Element {
|
fn render_menu(&self, cx: &mut RenderContext<Self>) -> impl Element {
|
||||||
enum Menu {}
|
enum Menu {}
|
||||||
enum MenuItem {}
|
enum MenuItem {}
|
||||||
|
|
||||||
let style = cx.global::<Settings>().theme.context_menu.clone();
|
let style = cx.global::<Settings>().theme.context_menu.clone();
|
||||||
|
|
||||||
MouseEventHandler::<Menu>::new(0, cx, |_, cx| {
|
MouseEventHandler::<Menu>::new(0, cx, |_, cx| {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
|
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
|
||||||
match item {
|
match item {
|
||||||
ContextMenuItem::Item { label, action } => {
|
ContextMenuItem::Item { label, action } => {
|
||||||
let action = action.boxed_clone();
|
let action = action.boxed_clone();
|
||||||
|
|
||||||
MouseEventHandler::<MenuItem>::new(ix, cx, |state, _| {
|
MouseEventHandler::<MenuItem>::new(ix, cx, |state, _| {
|
||||||
let style =
|
let style =
|
||||||
style.item.style_for(state, Some(ix) == self.selected_index);
|
style.item.style_for(state, Some(ix) == self.selected_index);
|
||||||
|
@ -350,6 +353,7 @@ impl ContextMenu {
|
||||||
cx.dispatch_action(Clicked);
|
cx.dispatch_action(Clicked);
|
||||||
cx.dispatch_any_action(action.boxed_clone());
|
cx.dispatch_any_action(action.boxed_clone());
|
||||||
})
|
})
|
||||||
|
.on_drag(MouseButton::Left, |_, _| {})
|
||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
ContextMenuItem::Separator => Empty::new()
|
ContextMenuItem::Separator => Empty::new()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue