• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How to block/cancel mouse event?

bsabiston

Member
I have a big menu overlay that pops up from time to time, covering my regular object-based buttons. The menu is not an object -- I detect UI touches using mouse_check_button().

Is there a way that when I detect mouse down and handle the mouse click in my menu overlay, I can then cancel the mouse from going on and triggering the buttons underneath?

I know that with button click handling you can return true to say the event was handled. But in the case of mouse_check_button, there's no event (yet?). So can I get the event that is or would be generated and cancel that?

Thanks!
 
M

MONCEFDZ

Guest
with
Code:
exit;
the lines before this keyword will not stop
but the lines after the keyword will stop
i hope this what you mean
 

Yal

šŸ§ *penguin noises*
GMC Elder
Wrap all the code triggered by the normal buttons in something like
Code:
if not(instance_exists(obj_bigmenuthing){
   //Original code here
}
then it's not run if the menu exists.
 

bsabiston

Member
I appreciate why you would say that, but this is a special case that does not warrant rewriting the basic structure of a codebase thatā€™s already been used to publish two fairly successful games. Thanks to everyone who replied, I assumed there would be a way to do what I asked. But I have figured out a workaround which wonā€™t require major code reworking.
 

curato

Member
Yal got your answer you set a variable true false when the overlay is visable then put an if block around your mouse click on the objects. They will still detect the click but the if statement will cancel the undesired action.
 

TheouAegis

Member
Let's address the elephant in the room.

Suppose the menu is a moveable overlay, similar to most MMORPGs. A "if window is open" check won't work because the overlay could be over the other button or it could be on the other side of the screen, so neither would a state machine centered around a similar mechanic. You'd need to organize the game such that the overlay is guaranteed to run its code first and then mouse_clear(mb_any) afterward.
 
Top