Right Click Actions

I want to create a right click action that jumps to the next scene. How the heck do I do this?

This can be done with JavaScript. Basically, you’d need an event listener and detect a right click.

It requires custom JavaScript code, but it’s possible. I added a right click feature to one of my (unfinished) games.

https://photics.com/games/broom

1 Like

I did it! Thanks

Can I see some javascript that tells me how to go to a specific scene? I have a right click event set up, but I want a right click to trigger a scene change.

What’s the javascript command for go to scene “x” on right click?

Thanks:)

When you edit JavaScript in Hype, you should see the Hype API stuff at the bottom – with a section for scenes. More documentation is here…

…but basically it’s…

hypeDocument.showSceneNamed(sceneName, optionalTransition, optionalDuration)

You would run this ‘On Scene Load’ to capture the right click, and use it to go to a named scene:

window.oncontextmenu = function (){
  hypeDocument.showSceneNamed('Scene 2', hypeDocument.kSceneTransitionCrossfade, 1.1);
}

rightclick.zip (18.3 KB)

1 Like

WOW!!! Okay, that was pure perfection. Thanks!

How do I hide the browser right click menu? It keeps showing up.

Add one line:

window.oncontextmenu = function (){
  hypeDocument.showSceneNamed('Scene 2', hypeDocument.kSceneTransitionCrossfade, 1.1);
// this line means: Don't do what is normally done:   
return false;
}

Here’s a nice post about what return false; does:

2 Likes

That worked Daniel! Thanks!

1 Like