(resourceURL?: string)
| 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 |
nothing calls this directly
no test coverage detected