From 3b6e0e5802eadeabd93a5588a96ef0a9b77b7c6c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 8 Oct 2021 16:44:33 +0200 Subject: [PATCH] Fixes the PointerEvent.kind always being down Fixes #558 --- CHANGELOG.md | 6 +++++- sixtyfps_runtime/corelib/items.rs | 4 ++-- tests/cases/elements/toucharea.60 | 34 +++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95206d8ec..494507f54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,14 @@ All notable changes to this project will be documented in this file. ## Unreleased -### Changed +### Added - Enable support for compressed SVG (.svgz). +### Fixed + + - Fixed the PointerEvent.kind always being down + ## [0.1.3] - 2021-10-06 ### Changed diff --git a/sixtyfps_runtime/corelib/items.rs b/sixtyfps_runtime/corelib/items.rs index 9059f5441..c8d744452 100644 --- a/sixtyfps_runtime/corelib/items.rs +++ b/sixtyfps_runtime/corelib/items.rs @@ -427,7 +427,7 @@ impl Item for TouchArea { Self::FIELD_OFFSETS.pressed.apply_pin(self).set(false); Self::FIELD_OFFSETS.pointer_event.apply_pin(self).call(&(PointerEvent { button: PointerEventButton::none, - kind: PointerEventKind::down, + kind: PointerEventKind::cancel, },)); } MouseEvent::MouseReleased { button, .. } => { @@ -437,7 +437,7 @@ impl Item for TouchArea { Self::FIELD_OFFSETS .pointer_event .apply_pin(self) - .call(&(PointerEvent { button, kind: PointerEventKind::down },)); + .call(&(PointerEvent { button, kind: PointerEventKind::up },)); } MouseEvent::MouseMoved { .. } => { return if self.pressed() { diff --git a/tests/cases/elements/toucharea.60 b/tests/cases/elements/toucharea.60 index 144327447..637e3d042 100644 --- a/tests/cases/elements/toucharea.60 +++ b/tests/cases/elements/toucharea.60 @@ -12,6 +12,8 @@ TestCase := Rectangle { property touch2; property touch3; + property pointer-event-test; + TouchArea { x: 100phx; y: 100phx; @@ -31,9 +33,31 @@ TestCase := Rectangle { y: 100phx; width: 5phx; height: 5phx; - clicked => { touch2+=1; } + clicked => { + pointer-event-test += "click"; + touch2+=1; + } pointer-event(e) => { - if (e.kind == PointerEventKind.cancel || e.button == PointerEventButton.right) {} + if (e.kind == PointerEventKind.cancel) { + pointer-event-test += "cancel"; + } else if (e.kind == PointerEventKind.up) { + pointer-event-test += "up"; + } else if (e.kind == PointerEventKind.down) { + pointer-event-test += "down"; + } else { + pointer-event-test += "err"; + } + if (e.button == PointerEventButton.right) { + pointer-event-test += "right"; + } else if (e.button == PointerEventButton.left) { + pointer-event-test += "left"; + } else if (e.button == PointerEventButton.middle) { + pointer-event-test += "middle"; + } else if (e.button == PointerEventButton.none) { + pointer-event-test += "none"; + } else { + pointer-event-test += "other"; + } } } } @@ -67,6 +91,8 @@ assert_eq(instance.get_touch1(), 1); assert_eq(instance.get_touch2(), 1); assert_eq(instance.get_touch3(), 1); +assert_eq(instance.get_pointer_event_test(), "downleftclickupleft"); + ``` @@ -96,6 +122,8 @@ assert_eq!(instance.get_touch1(), 1); assert_eq!(instance.get_touch2(), 1); assert_eq!(instance.get_touch3(), 1); +assert_eq!(instance.get_pointer_event_test().as_str(), "downleftclickupleft"); + ``` ```js @@ -123,5 +151,7 @@ instance.send_mouse_click(106., 103.); assert.equal(instance.touch1, 1); assert.equal(instance.touch2, 1); assert.equal(instance.touch3, 1); + +assert.equal(instance.pointer_event_test, "downleftclickupleft"); ``` */