CodeWringer / strive-foundryVTT

STRIVE system for FoundryVTT
GNU General Public License v3.0
1 stars 0 forks source link

Add ContextMenu to actor sheet #67

Closed CodeWringer closed 10 months ago

CodeWringer commented 2 years ago

Show respective context menus on right click on items.

See also: https://foundryvtt.com/api/ContextMenu.html

/**
 * @type {ContextMenu}
 * @private
 */
_contextMenu = undefined;

// Show
this._contextMenu.render(this.element);
// Hide
this._contextMenu.close({ animate: true });

// In activateListeners
const menuItems = [{
  name: "a localized text",
  icon: "either an empty string, or an icon element in raw HTML",
  condition: () => { return true; }, // If this returns true, the menu item will be visible. 
  callback: () => { doStuff(); } // The actual callback that gets invoked when the menu item is clicked. 
}];
this._contextMenu = new ContextMenu(html, this.id, menuItems);