Only send one right click event
This commit is contained in:
parent
267e07472d
commit
9456f716c2
2 changed files with 23 additions and 18 deletions
|
@ -72,7 +72,10 @@ impl<V: 'static> Element<V> for Overlay<V> {
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.map(|child| child.layout(view_state, cx))
|
.map(|child| child.layout(view_state, cx))
|
||||||
.collect::<SmallVec<_>>();
|
.collect::<SmallVec<_>>();
|
||||||
let layout_id = cx.request_layout(&Style::default(), child_layout_ids.iter().copied());
|
let mut overlay_style = Style::default();
|
||||||
|
overlay_style.position = crate::Position::Absolute;
|
||||||
|
|
||||||
|
let layout_id = cx.request_layout(&overlay_style, child_layout_ids.iter().copied());
|
||||||
|
|
||||||
(layout_id, OverlayState { child_layout_ids })
|
(layout_id, OverlayState { child_layout_ids })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
|
||||||
let event = unsafe { InputEvent::from_native(native_event, Some(window_height)) };
|
let event = unsafe { InputEvent::from_native(native_event, Some(window_height)) };
|
||||||
|
|
||||||
if let Some(mut event) = event {
|
if let Some(mut event) = event {
|
||||||
let synthesized_second_event = match &mut event {
|
match &mut event {
|
||||||
InputEvent::MouseDown(
|
InputEvent::MouseDown(
|
||||||
event @ MouseDownEvent {
|
event @ MouseDownEvent {
|
||||||
button: MouseButton::Left,
|
button: MouseButton::Left,
|
||||||
|
@ -1149,6 +1149,7 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
|
// On mac, a ctrl-left click should be handled as a right click.
|
||||||
*event = MouseDownEvent {
|
*event = MouseDownEvent {
|
||||||
button: MouseButton::Right,
|
button: MouseButton::Right,
|
||||||
modifiers: Modifiers {
|
modifiers: Modifiers {
|
||||||
|
@ -1158,26 +1159,30 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
|
||||||
click_count: 1,
|
click_count: 1,
|
||||||
..*event
|
..*event
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(InputEvent::MouseDown(MouseDownEvent {
|
|
||||||
button: MouseButton::Right,
|
|
||||||
..*event
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because we map a ctrl-left_down to a right_down -> right_up let's ignore
|
// Because we map a ctrl-left_down to a right_down -> right_up let's ignore
|
||||||
// the ctrl-left_up to avoid having a mismatch in button down/up events if the
|
// the ctrl-left_up to avoid having a mismatch in button down/up events if the
|
||||||
// user is still holding ctrl when releasing the left mouse button
|
// user is still holding ctrl when releasing the left mouse button
|
||||||
InputEvent::MouseUp(MouseUpEvent {
|
InputEvent::MouseUp(
|
||||||
button: MouseButton::Left,
|
event @ MouseUpEvent {
|
||||||
modifiers: Modifiers { control: true, .. },
|
button: MouseButton::Left,
|
||||||
..
|
modifiers: Modifiers { control: true, .. },
|
||||||
}) => {
|
..
|
||||||
lock.synthetic_drag_counter += 1;
|
},
|
||||||
return;
|
) => {
|
||||||
|
*event = MouseUpEvent {
|
||||||
|
button: MouseButton::Right,
|
||||||
|
modifiers: Modifiers {
|
||||||
|
control: false,
|
||||||
|
..event.modifiers
|
||||||
|
},
|
||||||
|
click_count: 1,
|
||||||
|
..*event
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => None,
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
match &event {
|
match &event {
|
||||||
|
@ -1227,9 +1232,6 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
|
||||||
if let Some(mut callback) = lock.event_callback.take() {
|
if let Some(mut callback) = lock.event_callback.take() {
|
||||||
drop(lock);
|
drop(lock);
|
||||||
callback(event);
|
callback(event);
|
||||||
if let Some(event) = synthesized_second_event {
|
|
||||||
callback(event);
|
|
||||||
}
|
|
||||||
window_state.lock().event_callback = Some(callback);
|
window_state.lock().event_callback = Some(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue