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

Method handleItemClick

packages/fairygui/src/widgets/PopupMenu.ts:287–319  ·  view source on GitHub ↗
(itemObject: GObject)

Source from the content-addressed store, hash-verified

285 }
286
287 private handleItemClick(itemObject: GObject): void {
288 if (!(itemObject instanceof GButton)) {
289 return;
290 }
291
292 if (itemObject.grayed) {
293 this._list.selectedIndex = -1;
294 return;
295 }
296
297 const c = itemObject.getController('checked');
298 if (c && c.selectedIndex !== 0) {
299 if (c.selectedIndex === 1) {
300 c.selectedIndex = 2;
301 } else {
302 c.selectedIndex = 1;
303 }
304 }
305
306 const r = this._contentPane.parent as GRoot | null;
307 if (r) {
308 r.hidePopup(this._contentPane);
309 }
310
311 const handler = itemObject.data as SimpleHandler | null;
312 if (handler) {
313 if (typeof handler === 'function') {
314 handler();
315 } else if (typeof handler.run === 'function') {
316 handler.run();
317 }
318 }
319 }
320
321 private onAddedToStage(): void {
322 this._list.selectedIndex = -1;

Callers 1

onClickItemMethod · 0.95

Calls 3

handlerFunction · 0.85
hidePopupMethod · 0.80
getControllerMethod · 0.45

Tested by

no test coverage detected