diff --git a/packages/framework/src/ui/PhaserBridge.tsx b/packages/framework/src/ui/PhaserBridge.tsx index 9e24daa..9737441 100644 --- a/packages/framework/src/ui/PhaserBridge.tsx +++ b/packages/framework/src/ui/PhaserBridge.tsx @@ -37,6 +37,7 @@ export const defaultPhaserConfig: Phaser.Types.Core.GameConfig = { parent: "phaser-container", backgroundColor: "#f9fafb", scene: [], + disableContextMenu: true, }; export interface PhaserGameProps { diff --git a/packages/framework/src/utils/dnd.ts b/packages/framework/src/utils/dnd.ts index 2b9c7ba..0bf0723 100644 --- a/packages/framework/src/utils/dnd.ts +++ b/packages/framework/src/utils/dnd.ts @@ -2,6 +2,7 @@ type PointerRecord = { id: number; + button: number; x: number; y: number; }; @@ -10,6 +11,7 @@ export enum DragDropEventType { DOWN, UP, MOVE, + ALTBUTTON, } export type DragDropEvent = { @@ -29,9 +31,22 @@ export function dragDropEventEffect( let down: PointerRecord | null = null; function onPointerDown(pointer: Phaser.Input.Pointer) { - if (isDragging) return; + if (down !== null) { + if (pointer.button === down.button) return; + callback({ + type: DragDropEventType.ALTBUTTON, + deltaX: pointer.x - down.x, + deltaY: pointer.y - down.y, + }); + return; + } isDragging = true; - down = { id: pointer.id, x: pointer.x, y: pointer.y }; + down = { + id: pointer.id, + button: pointer.button, + x: pointer.x, + y: pointer.y, + }; const event: DragDropEvent = { type: DragDropEventType.DOWN, @@ -42,12 +57,23 @@ export function dragDropEventEffect( } function onPointerUp(pointer: Phaser.Input.Pointer) { - if (!isDragging || !down || pointer.id !== down.id) return; + if ( + !isDragging || + !down || + pointer.id !== down.id || + pointer.button !== down.button + ) + return; - isDragging = false; const deltaX = pointer.x - down.x; const deltaY = pointer.y - down.y; - const event: DragDropEvent = { type: DragDropEventType.UP, deltaX, deltaY }; + + isDragging = false; + const event: DragDropEvent = { + type: DragDropEventType.UP, + deltaX, + deltaY, + }; callback(event); down = null; }