-
Notifications
You must be signed in to change notification settings - Fork 0
/
qinoq-morph.js
56 lines (49 loc) · 1.37 KB
/
qinoq-morph.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { DeserializationAwareMorph } from './utilities/deserialization-morph.js';
// QinoqMorphs are components of the editor
export class QinoqMorph extends DeserializationAwareMorph {
static get properties () {
return {
_editor: {},
halosEnabled: {
get () {
return this.editor && this.editor.debug;
}
},
acceptsDrops: {
defaultValue: false
},
// Propagate events targeting this morph, which would target the eventPropagationTarget if this morph
// would be removed. Only implemented for onContextMenu.
eventPropagationTarget: {}
};
}
get isQinoqMorph () {
return true;
}
get editor () {
return this._editor;
}
get interactive () {
return this.editor.interactive;
}
onMouseDown (event) {
super.onMouseDown(event);
if (!event.targetMorph.mayBeSelected) $world.get('interactives editor').execCommand('deselect all items');
}
onContextMenu (event) {
if (this.eventPropagationTarget) {
if (event.targetMorph == this && event.targetMorphs[1] == this.eventPropagationTarget) {
event.targetMorphs.shift();
this.eventPropagationTarget.onContextMenu(event);
}
} else {
super.onContextMenu(event);
}
}
menuItems () {
if (this.editor && this.editor.debug) {
return super.menuItems();
}
return [];
}
}