Fixes the PointerEvent.kind always being down

Fixes #558
This commit is contained in:
Olivier Goffart 2021-10-08 16:44:33 +02:00
parent 2983ae48c4
commit 3b6e0e5802
3 changed files with 39 additions and 5 deletions

View file

@ -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

View file

@ -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() {

View file

@ -12,6 +12,8 @@ TestCase := Rectangle {
property <int> touch2;
property <int> touch3;
property <string> 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");
```
*/