mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 21:58:13 +00:00
Support events other than 'contextmenu'
This commit is contained in:
@ -13,15 +13,21 @@ class ContextMenuRegistry {
|
|||||||
this._allActions.push(actionDefinition);
|
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) => {
|
let showContextMenu = (event) => {
|
||||||
this._showContextMenuForObjectPath(event, objectPath);
|
this._showContextMenuForObjectPath(event, objectPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
targetElement.addEventListener('contextmenu', showContextMenu);
|
targetElement.addEventListener(eventName, showContextMenu);
|
||||||
|
|
||||||
return function detach() {
|
return function detach() {
|
||||||
targetElement.removeEventListener('contextMenu', showContextMenu);
|
targetElement.removeEventListener(eventName, showContextMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user