mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
fix(input): avoid duplicate WeChat touch events (#381)
* fix(input): avoid duplicate WeChat touch events * update pal version * update pal version
This commit is contained in:
+12
-4
@@ -380,9 +380,15 @@ export class Input {
|
||||
}
|
||||
|
||||
if (sys.hasFeature(sys.Feature.EVENT_MOUSE)) {
|
||||
// WeChat PC maps the left mouse button and configured keyboard/mouse controls to touch events.
|
||||
// Use those platform touch events to avoid duplicates, while continuing to dispatch mouse events.
|
||||
// https://developers.weixin.qq.com/minigame/dev/guide/open-ability/pc-game.html
|
||||
const shouldSimulateTouch = !sys.hasFeature(sys.Feature.INPUT_TOUCH);
|
||||
mouseInput.on(InputEventType.MOUSE_DOWN, (event): void => {
|
||||
self._needSimulateTouchMoveEvent = true;
|
||||
self._simulateEventTouch(event);
|
||||
if (shouldSimulateTouch) {
|
||||
self._needSimulateTouchMoveEvent = true;
|
||||
self._simulateEventTouch(event);
|
||||
}
|
||||
self._dispatchEventMouse(event);
|
||||
});
|
||||
mouseInput.on(InputEventType.MOUSE_MOVE, (event): void => {
|
||||
@@ -392,8 +398,10 @@ export class Input {
|
||||
self._dispatchEventMouse(event);
|
||||
});
|
||||
mouseInput.on(InputEventType.MOUSE_UP, (event): void => {
|
||||
self._needSimulateTouchMoveEvent = false;
|
||||
self._simulateEventTouch(event);
|
||||
if (shouldSimulateTouch) {
|
||||
self._needSimulateTouchMoveEvent = false;
|
||||
self._simulateEventTouch(event);
|
||||
}
|
||||
self._dispatchEventMouse(event);
|
||||
});
|
||||
mouseInput.on(InputEventType.MOUSE_WHEEL, (event): void => {
|
||||
|
||||
Generated
+5
-4
@@ -15,7 +15,7 @@
|
||||
"@cocos/cannon": "1.2.8",
|
||||
"@cocos/ccbuild": "^2.3.21",
|
||||
"@cocos/dragonbones-js": "^1.0.1",
|
||||
"@cocos/engine-pal": "^1.0.5",
|
||||
"@cocos/engine-pal": "^1.0.6",
|
||||
"@cocos/engine-platforms": "^1.0.6",
|
||||
"@types/jest": "^24.9.1"
|
||||
},
|
||||
@@ -2568,9 +2568,10 @@
|
||||
"integrity": "sha512-1bWAW8td2WTGicyCqxtpIjc1YuK5EzMWfMEWaJlskPAQwLS0JfxEGka71sZ1BzudiWiKS7hPMg+FvXr5NRnVwQ=="
|
||||
},
|
||||
"node_modules/@cocos/engine-pal": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@cocos/engine-pal/-/engine-pal-1.0.5.tgz",
|
||||
"integrity": "sha512-KTqpQ/+GqjVr+iiyD58soC999Yg9zrpnQypwTAb550rrAY5Er/NVvhnneRzs6zAcMrxuWUY0dKQGXzAQghqz4w=="
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@cocos/engine-pal/-/engine-pal-1.0.6.tgz",
|
||||
"integrity": "sha512-CurR0yDbdRUSyOu8R939Y0jq1UDd+ZTFyPKDN9J9SlsLRAjImtIwGcfQ+yohdgr3UxV4oFuLEjIAdcHJTvMafg==",
|
||||
"license": "UNLICENSED"
|
||||
},
|
||||
"node_modules/@cocos/engine-platforms": {
|
||||
"version": "1.0.6",
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@
|
||||
"@cocos/cannon": "1.2.8",
|
||||
"@cocos/ccbuild": "^2.3.21",
|
||||
"@cocos/dragonbones-js": "^1.0.1",
|
||||
"@cocos/engine-pal": "^1.0.5",
|
||||
"@cocos/engine-pal": "^1.0.6",
|
||||
"@cocos/engine-platforms": "^1.0.6",
|
||||
"@types/jest": "^24.9.1"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user