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

Method addItemAt

packages/fairygui/src/widgets/PopupMenu.ts:104–121  ·  view source on GitHub ↗

* Add a menu item at specified index * 在指定索引处添加菜单项

(caption: string, index: number, handler?: SimpleHandler)

Source from the content-addressed store, hash-verified

102 * 在指定索引处添加菜单项
103 */
104 public addItemAt(caption: string, index: number, handler?: SimpleHandler): GButton {
105 const item = this._list.getFromPool();
106 if (!item || !(item instanceof GButton)) {
107 throw new Error('Failed to create menu item');
108 }
109
110 this._list.addChildAt(item, index);
111 item.title = caption;
112 item.data = handler;
113 item.grayed = false;
114
115 const c = item.getController('checked');
116 if (c) {
117 c.selectedIndex = 0;
118 }
119
120 return item;
121 }
122
123 /**
124 * Add a separator

Callers

nothing calls this directly

Calls 3

getFromPoolMethod · 0.80
addChildAtMethod · 0.45
getControllerMethod · 0.45

Tested by

no test coverage detected