MCPcopy Create free account
hub / github.com/esengine/esengine / constructor

Method constructor

packages/fairygui/src/widgets/PopupMenu.ts:41–68  ·  view source on GitHub ↗
(resourceURL?: string)

Source from the content-addressed store, hash-verified

39 protected _list: GList;
40
41 constructor(resourceURL?: string) {
42 if (!resourceURL) {
43 resourceURL = getUIConfig('popupMenu');
44 if (!resourceURL) {
45 throw new Error('UIConfig.popupMenu not defined');
46 }
47 }
48
49 const obj = UIPackage.createObjectFromURL(resourceURL);
50 if (!obj || !(obj instanceof GComponent)) {
51 throw new Error(`Failed to create popup menu from: ${resourceURL}`);
52 }
53
54 this._contentPane = obj;
55 this._contentPane.on(FGUIEvents.DISPLAY, this.onAddedToStage, this);
56
57 const list = this._contentPane.getChild('list');
58 if (!list || !(list instanceof GList)) {
59 throw new Error('PopupMenu content pane must have a child named "list" of type GList');
60 }
61
62 this._list = list;
63 this._list.removeChildrenToPool();
64 this._list.relations.add(this._contentPane, ERelationType.Width);
65 this._list.relations.remove(this._contentPane, ERelationType.Height);
66 this._contentPane.relations.add(this._list, ERelationType.Height);
67 this._list.on(FGUIEvents.CLICK_ITEM, this.onClickItem, this);
68 }
69
70 /**
71 * Dispose the menu

Callers

nothing calls this directly

Calls 7

getUIConfigFunction · 0.90
removeChildrenToPoolMethod · 0.80
removeMethod · 0.65
createObjectFromURLMethod · 0.45
onMethod · 0.45
getChildMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected