how can you detect a click that was made outside the required component?
I want to make something like a context menu on the Windows OS desktop, I did the positioning when I click on the frame, but I don’t know how I can detect the click outside of the menu to hide it. Do you have any suggestions?
21 Replies
Click outside of the window?
Wdym
like
are you using windows?
OS
anyways
if you right click somewhere on the desktop a menu will appear
it won't disappear unless you click somewhere outside of that menu
I'm trying to do something like that
But I can't figure out how to hide it
Context menu you mean?
ah right
context menu
yeah
Can you add full screen button that if you click on will hide it
Or can listen to mouse input and check if the click is outside?
Sounds like not the best solution to be honest, are there any other options? Or is this the simplest one
It is the simplest
. 2.
I did it a couple times and it worked flawlessly
But anyway
but how can I prevent the click on that button from happening in the context menu, ZIndex?
You just put the context menu above the button
Do you use react?
I do
Or another thing I found that it's sometimes easier to use Z-index behaviour global
It mimics html good
Esp for context menus
I see
Anyway
Now the question is how to position the click off button
Btw
hm?
If you listen to the mouse input instead you will be able to replicate the real context menu I think
Since with the click off button you will have to click one more time
Can you actually do InputService.InputBegan for now
And check if the input is touch or mouse click
okay
If I do it that way, how do I calculate if the click was outside of the frame
Solved, if anyone needs it:
hate when the if statement looks very spreaded like
it makes a bit unreadable
true