Skip to content

contextmenu support and missing contextMenu event #523

Description

@nuno-agostinho

Hi, I have two issues related to context menu handling in phylotree.js:

  1. Allow to show context menu using the contextmenu event (as asked by Allow menu to be shown on 'contextmenu' #446), even if not enabled by default.
  2. Fix the contextMenu event emission: I was trying to do what I said by manually simulating a user click, but I do not think this event is emitted, so this does not work:
tree.on("contextMenu", (node, event) => {
    event.preventDefault();

    console.log(node, event);
	
	event.target.dispatchEvent(new MouseEvent("click", {
		bubbles: true,
		cancelable: true,
		view: window,
		clientX: event.clientX,
		clientY: event.clientY,
		screenX: event.screenX,
		screenY: event.screenY,
		pageX: event.pageX,
		pageY: event.pageY
	}));

    return false;
});

Thanks for this library!

All the best,
Nuno

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions