Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceInputSystem: Use correct pointerId for touch inputs on blur and pointercancel event #13516

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/dev/core/src/DeviceInput/eventFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class DeviceEventFactory {
inputIndex: number,
currentState: Nullable<number>,
deviceInputSystem: IDeviceInputSystem,
elementToAttachTo?: any
elementToAttachTo?: any,
pointerId?: number
): IUIEvent {
switch (deviceType) {
case DeviceType.Keyboard:
Expand All @@ -37,7 +38,7 @@ export class DeviceEventFactory {
}
// eslint-disable-next-line no-fallthrough
case DeviceType.Touch:
return this._CreatePointerEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);
return this._CreatePointerEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo, pointerId);
default:
throw `Unable to generate event for device ${DeviceType[deviceType]}`;
}
Expand All @@ -60,7 +61,8 @@ export class DeviceEventFactory {
inputIndex: number,
currentState: Nullable<number>,
deviceInputSystem: IDeviceInputSystem,
elementToAttachTo?: any
elementToAttachTo?: any,
pointerId?: number
): any {
const evt = this._CreateMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);

Expand All @@ -70,7 +72,7 @@ export class DeviceEventFactory {
evt.pointerType = "mouse";
} else {
evt.deviceType = DeviceType.Touch;
evt.pointerId = deviceSlot;
evt.pointerId = pointerId ?? deviceSlot;
evt.pointerType = "touch";
}

Expand Down
20 changes: 18 additions & 2 deletions packages/dev/core/src/DeviceInput/webDeviceInputSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,15 @@ export class WebDeviceInputSystem implements IDeviceInputSystem {

this._inputs[DeviceType.Touch][deviceSlot][PointerInput.LeftClick] = 0;

const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 0, this, this._elementToAttachTo);
const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(
DeviceType.Touch,
deviceSlot,
PointerInput.LeftClick,
0,
this,
this._elementToAttachTo,
evt.pointerId
);

this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);

Expand Down Expand Up @@ -662,7 +670,15 @@ export class WebDeviceInputSystem implements IDeviceInputSystem {
if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {
pointer[deviceSlot][PointerInput.LeftClick] = 0;

const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 0, this, this._elementToAttachTo);
const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(
DeviceType.Touch,
deviceSlot,
PointerInput.LeftClick,
0,
this,
this._elementToAttachTo,
pointerId
);

this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);

Expand Down