Mouse click actions getting triggered on right-click also

I have added mouse-click actions (Go to URLs, mostly) which get triggered even on right mouse clicks.

Is there a way for the user to open the links in a new tab if they wish to? As far as I know, right click > open link in new tab won’t work for JS based links and they work only for HTML anchor tags, but, just confirming.

Basically correct. Users can command-click on links and the Go to URL has an option to open in a new window which for all intents and purposes is a new tab nowadays.

Other than that, if you want to have the context menu behave like a link, you will need to embed a <a href="http://example.com"></a> tag within Inner HTML.

But is there any way to disable links getting triggered on right click?

Yes, you can disable the menu entirely. There are some standard javascript ways in which it can be done:

It is considered user-hostile to do this; please be sure you have a good reason!

No no, not the menu. I’m saying the links on my website are getting triggered even when users right click.

Like, suppose I have a button with a onmouseclick action set to go to a url. So, this button opens the link even when the user right clicks on it.

You can try it on any button or object with link on my website: https://www.brokenhearts.ml/index.html

I’d like to disable this right click behaviour.

Ah, gotchya. Yet my testing does not have this behavior and your site doesn’t look like it is loading properly right now.

When I do a two-finger click on my macbook pro trackpad to invoke the context menu, it shows up and the Go to URL action is not triggered. I’m running macOS 10.14 and testing against the latest Safari and Chrome.

How are you triggering a right click? What browser/OS and version are you using? What mouse are you using? Do you have a more reduced case in a .hype document you can send?

I’m trying it on my Windows 10 Pro 1903 laptop in Google Chrome Canary 76 (in Guest account i.e., free from any cache, cookies and extensions - almost like incognito). I’m using an external 3-button mouse, even though, the right click on my trackpad is also doing the same thing. It does load the context menu, but, also triggers the Go to URL. This is happening on the entire website.

Here’s a short screen recording of what’s happening:

Also, I tried this on my mac on which I’m developing, so, yeah, the context menu does load, but, sometimes, the Go to URL is getting triggered on multiple right-clicks. One pattern I noticed that, on first right-click, only the contect menu loads and if we right-click again without dismissing the context menu, the Go to URL is triggered. While, if we dismiss the context menu and right click, the menu loads again. Here’s a video of that:

Here’s the .hype document (zipped), with just the Home scene:

Links.hype.zip (368.9 KB)

Edit: Canary got updated to Chrome 77, stillhe same.

Thanks - it looks like while we check to avoid running actions on a mousedown event, mouseups (which would seem unlikely but can happen in situations like the mac+chrome one) and pointerup (for windows) wasn’t filtering this out. I’ve made a fix for the next version after 4.0.0.

In the mean time if this is a high priority issue to avoid, the workaround would be to use a run javascript action and use a check to determine if a right/control click was used instead of the Go to URL action. It’d be something like:

if(event.ctrlKey == true || event.button != 0) {
    return;
}

// do action you want
location.href = "http://example.com";
1 Like

Thanks for the information! It’s not very high priority right now, but, I’d still use JS at some common places.

1 Like