-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
572 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/core/src/Player/service/PlayerDoubleClickEventService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { DisplayObject } from "@next2d/display"; | ||
import { $stage } from "@next2d/display"; | ||
import { PointerEvent } from "@next2d/events"; | ||
|
||
/** | ||
* @description ポインターのダブルタップイベントを処理します。 | ||
* Processes the pointer double tap event. | ||
* | ||
* @param {D | null} display_object | ||
* @return {void} | ||
* @method | ||
* @protected | ||
*/ | ||
export const execute = <D extends DisplayObject> (display_object: D | null = null): void => | ||
{ | ||
if (display_object) { | ||
if (display_object.willTrigger(PointerEvent.DOUBLE_CLICK)) { | ||
display_object.dispatchEvent( | ||
new PointerEvent(PointerEvent.DOUBLE_CLICK) | ||
); | ||
} | ||
} else { | ||
if ($stage.willTrigger(PointerEvent.DOUBLE_CLICK)) { | ||
$stage.dispatchEvent( | ||
new PointerEvent(PointerEvent.DOUBLE_CLICK) | ||
); | ||
} | ||
} | ||
}; |
80 changes: 80 additions & 0 deletions
80
packages/core/src/Player/service/PlayerPointerDownEventService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { DisplayObject } from "@next2d/display"; | ||
import type { TextField } from "@next2d/text"; | ||
import { $stage } from "@next2d/display"; | ||
import { PointerEvent } from "@next2d/events"; | ||
import { | ||
$setSelectedTextField, | ||
$getSelectedTextField, | ||
$textArea | ||
} from "@next2d/text"; | ||
import { | ||
$hitObject, | ||
$hitMatrix | ||
} from "../../CoreUtil"; | ||
|
||
/** | ||
* @description ポインターダウンイベントを処理します。 | ||
* Processes the pointer down event. | ||
* | ||
* @param {D | null} display_object | ||
* @return {void} | ||
* @method | ||
* @protected | ||
*/ | ||
export const execute = <D extends DisplayObject> ( | ||
display_object: D | null = null, | ||
page_x: number = 0, | ||
page_y: number = 0 | ||
): void => { | ||
|
||
if (display_object) { | ||
|
||
if (display_object.isText) { | ||
|
||
// 選択中のTextFieldがある場合はフォーカスを解除します。 | ||
const selectedTextField = $getSelectedTextField(); | ||
if (selectedTextField | ||
&& selectedTextField.instanceId !== display_object.instanceId | ||
) { | ||
selectedTextField.focus = false; | ||
} | ||
|
||
if (!(display_object as unknown as TextField).focus) { | ||
(display_object as unknown as TextField).focus = true; | ||
$setSelectedTextField(display_object as unknown as TextField); | ||
} | ||
|
||
(display_object as unknown as TextField).setFocusIndex( | ||
$hitObject.x - $hitMatrix[4], | ||
$hitObject.y - $hitMatrix[5] | ||
); | ||
|
||
$textArea.style.top = `${page_x}px`; | ||
$textArea.style.left = `${page_y}px`; | ||
|
||
} else { | ||
// ヒットしたDisplayObjectポインターダウンイベントを発火します。 | ||
if (display_object.willTrigger(PointerEvent.POINTER_DOWN)) { | ||
display_object.dispatchEvent( | ||
new PointerEvent(PointerEvent.POINTER_DOWN) | ||
); | ||
} | ||
} | ||
|
||
} else { | ||
|
||
// 選択中のTextFieldがある場合はフォーカスを解除します。 | ||
const selectedTextField = $getSelectedTextField(); | ||
if (selectedTextField) { | ||
selectedTextField.focus = false; | ||
$setSelectedTextField(null); | ||
} | ||
|
||
// ステージ全体のポインターダウンイベントを発火します。 | ||
if ($stage.willTrigger(PointerEvent.POINTER_DOWN)) { | ||
$stage.dispatchEvent( | ||
new PointerEvent(PointerEvent.POINTER_DOWN) | ||
); | ||
} | ||
} | ||
}; |
34 changes: 34 additions & 0 deletions
34
packages/core/src/Player/service/PlayerPointerMoveEventService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { DisplayObject } from "@next2d/display"; | ||
import type { TextField } from "@next2d/text"; | ||
import { $player } from "../../Player"; | ||
import { | ||
$hitObject, | ||
$hitMatrix | ||
} from "../../CoreUtil"; | ||
|
||
/** | ||
* @description ポインタームーブイベントを処理します。 | ||
* Processes the pointer move event. | ||
* | ||
* @param {D | null} display_object | ||
* @return {void} | ||
* @method | ||
* @protected | ||
*/ | ||
export const execute = <D extends DisplayObject> ( | ||
display_object: D | null = null, | ||
page_x: number = 0, | ||
page_y: number = 0 | ||
): void => { | ||
|
||
console.log(page_x, page_y); | ||
if (display_object) { | ||
if (display_object.isText && $player.mouseState === "down") { | ||
(display_object as unknown as TextField).setFocusIndex( | ||
$hitObject.x - $hitMatrix[4], | ||
$hitObject.y - $hitMatrix[5], | ||
true | ||
); | ||
} | ||
} | ||
}; |
29 changes: 29 additions & 0 deletions
29
packages/core/src/Player/service/PlayerPointerUpEventService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { DisplayObject } from "@next2d/display"; | ||
import { $stage } from "@next2d/display"; | ||
import { PointerEvent } from "@next2d/events"; | ||
|
||
/** | ||
* @description ポインターアップイベントを処理します。 | ||
* Processes the pointer up event. | ||
* | ||
* @param {DisplayObject | null} display_object | ||
* @return {void} | ||
* @method | ||
* @protected | ||
*/ | ||
export const execute = <D extends DisplayObject> (display_object: D | null = null): void => | ||
{ | ||
if (display_object) { | ||
if (display_object.willTrigger(PointerEvent.POINTER_UP)) { | ||
display_object.dispatchEvent( | ||
new PointerEvent(PointerEvent.POINTER_UP) | ||
); | ||
} | ||
} else { | ||
if ($stage.willTrigger(PointerEvent.POINTER_UP)) { | ||
$stage.dispatchEvent( | ||
new PointerEvent(PointerEvent.POINTER_UP) | ||
); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.