@awayjs/scene 0.13.239 → 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 +262 -303
- 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/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 +34 -38
- package/index.ts +1 -1
- package/lib/display/DisplayObject.ts +0 -21
- package/lib/display/DisplayObjectContainer.ts +0 -35
- package/lib/events/FocusEvent.ts +8 -1
- package/lib/events/MouseEvent.ts +8 -0
- package/lib/managers/MouseManager.ts +37 -39
- package/package.json +1 -1
|
@@ -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
|
|
|
@@ -746,15 +744,15 @@ export class MouseManager {
|
|
|
746
744
|
default:
|
|
747
745
|
break;
|
|
748
746
|
}
|
|
749
|
-
if (this.
|
|
750
|
-
//console.log("dispatch keydown on ", this.
|
|
747
|
+
if (this._focusNode || this._stage) {
|
|
748
|
+
//console.log("dispatch keydown on ", this._focusNode);
|
|
751
749
|
const newEvent: KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEYDOWN, event.key, event.code);
|
|
752
750
|
newEvent.isShift = event.shiftKey;
|
|
753
751
|
newEvent.isCTRL = event.ctrlKey;
|
|
754
752
|
newEvent.isAlt = event.altKey;
|
|
755
753
|
(<any>newEvent).keyCode = event.keyCode;
|
|
756
|
-
if (this.
|
|
757
|
-
this.
|
|
754
|
+
if (this._focusNode)
|
|
755
|
+
this._focusNode.container.dispatchEvent(newEvent);
|
|
758
756
|
if (this._stage)
|
|
759
757
|
this._stage.dispatchEvent(newEvent);
|
|
760
758
|
}
|
|
@@ -778,15 +776,15 @@ export class MouseManager {
|
|
|
778
776
|
break;
|
|
779
777
|
}
|
|
780
778
|
|
|
781
|
-
if (this.
|
|
782
|
-
//console.log("dispatch keydown on ", this.
|
|
779
|
+
if (this._focusNode || this._stage) {
|
|
780
|
+
//console.log("dispatch keydown on ", this._focusNode);
|
|
783
781
|
const newEvent: KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEYUP, event.key, event.code);
|
|
784
782
|
newEvent.isShift = event.shiftKey;
|
|
785
783
|
newEvent.isCTRL = event.ctrlKey;
|
|
786
784
|
newEvent.isAlt = event.altKey;
|
|
787
785
|
(<any>newEvent).keyCode = event.keyCode;
|
|
788
|
-
if (this.
|
|
789
|
-
this.
|
|
786
|
+
if (this._focusNode)
|
|
787
|
+
this._focusNode.container.dispatchEvent(newEvent);
|
|
790
788
|
if (this._stage)
|
|
791
789
|
this._stage.dispatchEvent(newEvent);
|
|
792
790
|
}
|