diff --git a/editor/js/tools/menus/collectmenu.js b/editor/js/tools/menus/collectmenu.js index ca181963b1954e700b82932ab76c84d401942b73..27295d6677d36129c793e95be1ed09c433c6dcf6 100644 --- a/editor/js/tools/menus/collectmenu.js +++ b/editor/js/tools/menus/collectmenu.js @@ -12,7 +12,6 @@ const DOM_LIST_ITEM = "li"; export class CollectMenu extends ToolMenu { constructor() { super(); - this.hooked = false; } hookClearButton() { @@ -22,12 +21,13 @@ export class CollectMenu extends ToolMenu { }); } - afterSet(key, value) { - if (this.hooked === false) { + onMenuShow(initial) { + if (initial) { this.hookClearButton(); - this.hooked = true; } + } + afterSet(key, value) { if (key === COLLECTION_KEY) { this.fillDomList(SELECTED_ITEMS_ID, value, this.itemListRenderer); } diff --git a/editor/js/tools/menus/toolmenu.js b/editor/js/tools/menus/toolmenu.js index 73c2ac7a3073662ebc293bbe0aaa9530301ff90a..af6004225774f615a35a01079580eece55c825fd 100644 --- a/editor/js/tools/menus/toolmenu.js +++ b/editor/js/tools/menus/toolmenu.js @@ -4,6 +4,7 @@ export default class ToolMenu { constructor() { this.warnings = false; this.values = {}; + this.initialShow = true; } loadTool(tool) { @@ -12,11 +13,26 @@ export default class ToolMenu { } show() { + this.onMenuShow(this.initialShow); + this.initialShow = false; this.getMenu().removeClass("hidden"); } hide() { this.getMenu().addClass("hidden"); + this.onMenuHide(); + } + + onMenuShow(initial) { + if (this.warnings) { + console.warn('Method "onMenuShow" not implemented.'); + } + } + + onMenuHide() { + if (this.warnings) { + console.warn('Method "onMenuHide" not implemented.'); + } } beforeGet(key) {