Bug/fixed character attack (#192)

* Fixed weapon useage in Character

* Added DHContextMenu to pass on the event from clicking a contextmenuitem
This commit is contained in:
WBHarry 2025-06-28 14:00:53 +02:00 committed by GitHub
parent e3b9dcad2a
commit 1f5b5f9915
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 40 additions and 15 deletions

View file

@ -0,0 +1,24 @@
export default class DhContextMenu extends ContextMenu {
constructor(container, selector, menuItems, options) {
super(container, selector, menuItems, options);
/** @deprecated since v13 until v15 */
this.#jQuery = options.jQuery;
}
#jQuery;
activateListeners(menu) {
menu.addEventListener('click', this.#onClickItem.bind(this));
}
#onClickItem(event) {
event.preventDefault();
event.stopPropagation();
const element = event.target.closest('.context-item');
if (!element) return;
const item = this.menuItems.find(i => i.element === element);
item?.callback(this.#jQuery ? $(this.target) : this.target, event);
this.close();
}
}