* Add a menu item at specified index * 在指定索引处添加菜单项
(caption: string, index: number, handler?: SimpleHandler)
| 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 |
nothing calls this directly
no test coverage detected