[solved] Contex menu By MolyKitty

I made my own contex menu and it works for PC, you can right click on the screen and get a contex menu.


TEST7-31-2022_21-47-50.wick (32.9 KB)
but I can’t make it work for mobile users (hold your finger on the screen)

This is not teleporting the menu when there are objects around where you clicked.

How to ignore nearby objects when you click near them?

maybe make everything inside a clip and put the context menu outside of that clip

1 Like

The function “isMouseDown()” should be helpful in this situation. It returns true if the mouse is pressed down anywhere in the project.

So, I added a simple counter to your project that increases when “isMouseDown()” is true, and resets to zero when not. The context menu appears when the counter goes over a specific value, in this case I used “10.” If you want the user to hold down longer before getting the context menu out, you can increase that value in line 9 of the update script of the context menu clip.

Here’s the project with my edits:
TEST.wick (32.9 KB)

I hope this helps :+1:

1 Like

this is super cool, but do you know if there is a way to not show the “real” context menu? if i right-click, i end up getting both the normal right-click menu and the one that you made.

this piece of code deactivates it (the real context menu) @awc95014

window.AddedEvent=false;
if(window.AddedEvent!==true){
    window.addEventListener("contextmenu", 
    function(){
        window.RClick=true;
    });
    window.AddedEvent=true;
}
1 Like

try this in the default script:

document.oncontextmenu = function(a){
    a.preventDefault();
}

Btw, when the project is paused this function is still there so you wouldn’t be able to right click.
This function is also run every time the user uses right clicks, so feel free to add in any other code in there.

2 Likes

I updated the menu, download it here.