@awayjs/scene 0.13.237 → 0.13.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/awayjs-scene.umd.js +283 -306
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/bundle/awayjs-scene.umd.min.js.map +1 -1
- package/bundle/awayjs-scene.umd.min.js.map.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/display/DisplayObject.d.ts +0 -5
- package/dist/lib/display/DisplayObject.d.ts.map +1 -1
- package/dist/lib/display/DisplayObject.js +0 -17
- package/dist/lib/display/DisplayObjectContainer.d.ts +0 -3
- package/dist/lib/display/DisplayObjectContainer.d.ts.map +1 -1
- package/dist/lib/display/DisplayObjectContainer.js +0 -31
- package/dist/lib/display/TextField.js +1 -1
- package/dist/lib/events/FocusEvent.d.ts +3 -1
- package/dist/lib/events/FocusEvent.d.ts.map +1 -1
- package/dist/lib/events/FocusEvent.js +5 -0
- package/dist/lib/events/MouseEvent.d.ts +1 -0
- package/dist/lib/events/MouseEvent.d.ts.map +1 -1
- package/dist/lib/events/MouseEvent.js +7 -0
- package/dist/lib/managers/MouseManager.d.ts +6 -4
- package/dist/lib/managers/MouseManager.d.ts.map +1 -1
- package/dist/lib/managers/MouseManager.js +54 -40
- package/index.ts +1 -1
- package/lib/display/DisplayObject.ts +0 -21
- package/lib/display/DisplayObjectContainer.ts +0 -35
- package/lib/display/TextField.ts +1 -1
- package/lib/events/FocusEvent.ts +8 -1
- package/lib/events/MouseEvent.ts +8 -0
- package/lib/managers/MouseManager.ts +57 -41
- package/package.json +1 -1
package/lib/events/MouseEvent.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Point, Vector3D, EventBase } from '@awayjs/core';
|
|
|
3
3
|
import { EntityNode, ContainerNode, INode, ITraversable, View } from '@awayjs/view';
|
|
4
4
|
|
|
5
5
|
import { IMaterial } from '@awayjs/renderer';
|
|
6
|
+
import FrameScriptManager from '../managers/FrameScriptManager';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A MouseEvent is dispatched when a mouse event occurs over a mouseEnabled object in View.
|
|
@@ -276,4 +277,11 @@ export class MouseEvent extends EventBase {
|
|
|
276
277
|
|
|
277
278
|
return sceneNormal;
|
|
278
279
|
}
|
|
280
|
+
|
|
281
|
+
public _dispatchEvent(dispatcher: ContainerNode) {
|
|
282
|
+
if (!dispatcher.isMouseDisabled()) {
|
|
283
|
+
dispatcher.container.dispatchEvent(this);
|
|
284
|
+
FrameScriptManager.execute_queue();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
279
287
|
}
|
|
@@ -2,6 +2,7 @@ import { Vector3D } from '@awayjs/core';
|
|
|
2
2
|
import { Stage } from '@awayjs/stage';
|
|
3
3
|
|
|
4
4
|
import { PickingCollision, RaycastPicker, ContainerNode, IPartitionContainer, EntityNode } from '@awayjs/view';
|
|
5
|
+
import { FocusEvent } from '../events/FocusEvent';
|
|
5
6
|
|
|
6
7
|
import { KeyboardEvent } from '../events/KeyboardEvent';
|
|
7
8
|
import { MouseEvent as AwayMouseEvent } from '../events/MouseEvent';
|
|
@@ -26,7 +27,7 @@ export class MouseManager {
|
|
|
26
27
|
|
|
27
28
|
private _mouseDragCollision: PickingCollision; // entity hit on mouse-down
|
|
28
29
|
private _mouseDragging: boolean; // true while mosue is dragged
|
|
29
|
-
private
|
|
30
|
+
private _focusNode: ContainerNode; // entity currently in focus
|
|
30
31
|
|
|
31
32
|
public allowKeyInput: boolean=true;
|
|
32
33
|
|
|
@@ -60,6 +61,9 @@ export class MouseManager {
|
|
|
60
61
|
private _dragStart: AwayMouseEvent = new AwayMouseEvent(AwayMouseEvent.DRAG_START);
|
|
61
62
|
private _dragStop: AwayMouseEvent = new AwayMouseEvent(AwayMouseEvent.DRAG_STOP);
|
|
62
63
|
|
|
64
|
+
private _focusIn: FocusEvent = new FocusEvent(FocusEvent.FOCUS_IN);
|
|
65
|
+
private _focusOut: FocusEvent = new FocusEvent(FocusEvent.FOCUS_OUT);
|
|
66
|
+
|
|
63
67
|
private _useSoftkeyboard: boolean = false;
|
|
64
68
|
|
|
65
69
|
public buttonEnabledDirty: boolean;
|
|
@@ -219,29 +223,35 @@ export class MouseManager {
|
|
|
219
223
|
|
|
220
224
|
}
|
|
221
225
|
|
|
222
|
-
public setFocus(
|
|
223
|
-
if (this.
|
|
226
|
+
public setFocus(node: ContainerNode) {
|
|
227
|
+
if (this._focusNode == node)
|
|
224
228
|
return;
|
|
225
|
-
}
|
|
226
|
-
if (this._focusContainer) {
|
|
227
|
-
this._focusContainer.setFocus(false, false);
|
|
228
|
-
}
|
|
229
|
-
this._focusContainer = obj;
|
|
230
229
|
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
// in FP6, a mouseclick on non focus-able object still steal the focus
|
|
231
|
+
// in newer FP they only steal the focus if the the new hit is focusable
|
|
232
|
+
if (this._allowFocusOnUnfocusable || this._focusNode.container.tabEnabled) {
|
|
233
|
+
if (this._focusNode) {
|
|
234
|
+
this.dispatchEvent(this._focusOut, this._focusNode);
|
|
235
|
+
this._focusNode.container.setFocus(false, true);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this._focusNode = node;
|
|
239
|
+
|
|
240
|
+
if (this._focusNode) {
|
|
241
|
+
this.dispatchEvent(this._focusIn, this._focusNode);
|
|
242
|
+
this._focusNode.container.setFocus(true, true);
|
|
243
|
+
}
|
|
233
244
|
}
|
|
234
245
|
}
|
|
235
246
|
|
|
236
247
|
public getFocus() {
|
|
237
|
-
return this.
|
|
248
|
+
return this._focusNode;
|
|
238
249
|
}
|
|
239
250
|
|
|
240
|
-
private dispatchEvent(event: AwayMouseEvent, dispatcher: ContainerNode) {
|
|
251
|
+
private dispatchEvent(event: AwayMouseEvent | FocusEvent, dispatcher: ContainerNode) {
|
|
241
252
|
if (!this._eventBubbling) {
|
|
242
253
|
if (dispatcher) {
|
|
243
|
-
|
|
244
|
-
FrameScriptManager.execute_queue();
|
|
254
|
+
event._dispatchEvent(dispatcher);
|
|
245
255
|
}
|
|
246
256
|
return;
|
|
247
257
|
}
|
|
@@ -250,10 +260,8 @@ export class MouseManager {
|
|
|
250
260
|
if (event.commonAncestor && dispatcher == event.commonAncestor) {
|
|
251
261
|
return;
|
|
252
262
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
FrameScriptManager.execute_queue();
|
|
256
|
-
}
|
|
263
|
+
event._dispatchEvent(dispatcher);
|
|
264
|
+
|
|
257
265
|
if (!event._iAllowedToPropagate) {
|
|
258
266
|
dispatcher = null;
|
|
259
267
|
} else {
|
|
@@ -324,20 +332,10 @@ export class MouseManager {
|
|
|
324
332
|
} else if (this._eventBubbling)
|
|
325
333
|
this._stage.dispatchEvent(event);
|
|
326
334
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (this._allowFocusOnUnfocusable || this._mouseDragCollision?.rootNode.container.tabEnabled) {
|
|
330
|
-
if (this._focusContainer)
|
|
331
|
-
this._focusContainer.setFocus(false, true);
|
|
332
|
-
|
|
333
|
-
this._focusContainer = this._mouseDragCollision?.rootNode?.container;
|
|
334
|
-
|
|
335
|
-
if (this._focusContainer)
|
|
336
|
-
this._focusContainer.setFocus(true, true);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (this._mouseDragCollision)
|
|
335
|
+
if (this._mouseDragCollision) {
|
|
336
|
+
this.setFocus(this._mouseDragCollision?.rootNode);
|
|
340
337
|
this.setupAndDispatchEvent(this._dragStart, event, this._mouseDragCollision);
|
|
338
|
+
}
|
|
341
339
|
|
|
342
340
|
} else if (event.type == AwayMouseEvent.MOUSE_UP) {
|
|
343
341
|
|
|
@@ -736,16 +734,25 @@ export class MouseManager {
|
|
|
736
734
|
|
|
737
735
|
//console.log("Keydown", event);
|
|
738
736
|
if (this.allowKeyInput) {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
737
|
+
switch (event.keyCode) {
|
|
738
|
+
case 37: // left
|
|
739
|
+
case 39: // right
|
|
740
|
+
case 38: // up
|
|
741
|
+
case 40: // down
|
|
742
|
+
event.preventDefault();
|
|
743
|
+
break;
|
|
744
|
+
default:
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
if (this._focusNode || this._stage) {
|
|
748
|
+
//console.log("dispatch keydown on ", this._focusNode);
|
|
742
749
|
const newEvent: KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEYDOWN, event.key, event.code);
|
|
743
750
|
newEvent.isShift = event.shiftKey;
|
|
744
751
|
newEvent.isCTRL = event.ctrlKey;
|
|
745
752
|
newEvent.isAlt = event.altKey;
|
|
746
753
|
(<any>newEvent).keyCode = event.keyCode;
|
|
747
|
-
if (this.
|
|
748
|
-
this.
|
|
754
|
+
if (this._focusNode)
|
|
755
|
+
this._focusNode.container.dispatchEvent(newEvent);
|
|
749
756
|
if (this._stage)
|
|
750
757
|
this._stage.dispatchEvent(newEvent);
|
|
751
758
|
}
|
|
@@ -758,17 +765,26 @@ export class MouseManager {
|
|
|
758
765
|
|
|
759
766
|
//console.log("Keyup", event);
|
|
760
767
|
if (this.allowKeyInput) {
|
|
761
|
-
|
|
768
|
+
switch (event.keyCode) {
|
|
769
|
+
case 37: // left
|
|
770
|
+
case 39: // right
|
|
771
|
+
case 38: // up
|
|
772
|
+
case 40: // down
|
|
773
|
+
event.preventDefault();
|
|
774
|
+
break;
|
|
775
|
+
default:
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
762
778
|
|
|
763
|
-
if (this.
|
|
764
|
-
//console.log("dispatch keydown on ", this.
|
|
779
|
+
if (this._focusNode || this._stage) {
|
|
780
|
+
//console.log("dispatch keydown on ", this._focusNode);
|
|
765
781
|
const newEvent: KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEYUP, event.key, event.code);
|
|
766
782
|
newEvent.isShift = event.shiftKey;
|
|
767
783
|
newEvent.isCTRL = event.ctrlKey;
|
|
768
784
|
newEvent.isAlt = event.altKey;
|
|
769
785
|
(<any>newEvent).keyCode = event.keyCode;
|
|
770
|
-
if (this.
|
|
771
|
-
this.
|
|
786
|
+
if (this._focusNode)
|
|
787
|
+
this._focusNode.container.dispatchEvent(newEvent);
|
|
772
788
|
if (this._stage)
|
|
773
789
|
this._stage.dispatchEvent(newEvent);
|
|
774
790
|
}
|