Fixed touch long press.

This commit is contained in:
Samuel Guerra 2023-09-14 21:06:52 -03:00
parent 2ba5edeaaa
commit 5e6dd4f0a7
3 changed files with 16 additions and 2 deletions

View File

@ -32,6 +32,10 @@
# Touch Events
* Context menu opens at the mouse cursor position on long press.
- It also does not close on tap out.
- Issue is probably in `LAYERS`.
* We want the same gesture in combo box of clicking and dragging to the option.
- Maybe use the swipe/fling gesture?

View File

@ -236,7 +236,7 @@ impl ClickArgs {
self.click_count.get() == 1
&& match &self.source {
ClickArgsSource::Mouse { button, .. } => *button == MouseButton::Right,
ClickArgsSource::Touch { is_tap, .. } => *is_tap,
ClickArgsSource::Touch { is_tap, .. } => !*is_tap,
ClickArgsSource::Shortcut { kind, .. } => *kind == ShortcutClick::Context,
}
}
@ -981,6 +981,11 @@ impl AppExtension for GestureManager {
if !args.propagation().is_stopped() {
CLICK_EVENT.notify(args.clone().into());
}
} else if let Some(args) = TOUCH_LONG_PRESS_EVENT.on(update) {
// Generate click events from touch long press.
if !args.propagation().is_stopped() {
CLICK_EVENT.notify(args.clone().into());
}
} else if let Some(args) = SHORTCUT_EVENT.on(update) {
// Run shortcut actions.
GESTURES_SV.write().on_shortcut(args);

View File

@ -1516,7 +1516,12 @@ impl LongPressGesture {
if !p.canceled && !p.propagation.is_stopped() {
for m in &args.touches {
if p.propagation == m.touch_propagation {
// !!: TODO, check if moved too far
let dist = p.position - m.position().to_vector();
let max = TOUCH.touch_config().get().tap_area;
if dist.x.abs() > max.width || dist.y.abs() > max.height {
p.canceled = true;
break;
}
} else {
p.canceled = true;
break;