You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use context menu to create some elements on the page so i need the exact location where I right-clicked. The "MouseEvent" parameter is the event when I left-clicked on the context-menu-item.
Please see the attached picture, I need the location indicated by the green arrow not the location indicated by the red arrow.
The text was updated successfully, but these errors were encountered:
I managed to get the coordinates of the context-menu using the below code, but that is not good enough.
If I right-click close to the edge of the screen, the context menu is displayed in a different position to fit it in the screen. In that case, the top-left position of the context menu is not the point where I right-clicked.
If there are sub-menus I'll get the position of the sub-menu instead of the main-menu
private getContextMenuOrigin = (contextMenuEvent: ExecuteContextMenuEvent): Coord =>
{
let menuItem = contextMenuEvent.event.target as HTMLElement;
let parent = menuItem.parentElement;
while (parent && !(parent.classList.contains("cdk-overlay-pane") && parent.classList.contains("ngx-contextmenu"))) {
parent = parent.parentElement;
}
if (!(parent.classList.contains("cdk-overlay-pane") && parent.classList.contains("ngx-contextmenu"))) return undefined;
var boundingRect = parent.getBoundingClientRect();
return new Coord(boundingRect.left, boundingRect.top);
}
@nicolaedaian I manage to get away with this issue by using the contextMenuComponent.event (you can have a ViewChild of it).
Then you can have the event.clientX, event.ClientY.
I use context menu to create some elements on the page so i need the exact location where I right-clicked. The "MouseEvent" parameter is the event when I left-clicked on the context-menu-item.
Please see the attached picture, I need the location indicated by the green arrow not the location indicated by the red arrow.
The text was updated successfully, but these errors were encountered: