mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +00:00
Support events other than 'contextmenu'
This commit is contained in:
parent
a7948ce83e
commit
94cdce3551
@ -13,15 +13,21 @@ class ContextMenuRegistry {
|
||||
this._allActions.push(actionDefinition);
|
||||
}
|
||||
|
||||
attachTo(targetElement, objectPath) {
|
||||
attachTo(targetElement, objectPath, eventName) {
|
||||
eventName = eventName || 'contextmenu';
|
||||
|
||||
if (eventName !== 'contextmenu' && eventName !== 'click') {
|
||||
throw `'${eventName}' event not supported for context menu`;
|
||||
}
|
||||
|
||||
let showContextMenu = (event) => {
|
||||
this._showContextMenuForObjectPath(event, objectPath);
|
||||
};
|
||||
|
||||
targetElement.addEventListener('contextmenu', showContextMenu);
|
||||
targetElement.addEventListener(eventName, showContextMenu);
|
||||
|
||||
return function detach() {
|
||||
targetElement.removeEventListener('contextMenu', showContextMenu);
|
||||
targetElement.removeEventListener(eventName, showContextMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user