Game Development Community

Sprite based GUI mouse click through issue.

by Majicpanda · in Torque Game Builder · 07/15/2012 (1:42 am) · 3 replies

I've decided to use both the gui and sprite based gui system based on my current needs, and I've ran into the issue where a loot window pops up on layer 5 allows you to hover over say a worldmap behind it and display tooltips and also click to move to that location.

Question, how do you either capture or prevent mouse click through on objects so that a sprite or object can block this? The only solution I can think of would involve layers and preventing anything beyond layer 10 from being clicked or hovered if I set all my GUI to layers 0-9.

Any help is appreciated.

#1
07/16/2012 (11:15 am)
If I understand your question, it is "how do you stop mouse events from going to multiple levels?"

The answer is you can't.

I made a patch once, if you are willing to touch the C++ code. It allows you to stop on the first layer that accepts the mouse.
#2
07/16/2012 (11:35 am)
You can make the behavior conditional to a certain degree. So, from my understanding, you have a loot pop-up box on the map & when you click on the map normally it takes it as a move command. In the OnMousedown portion to process movement, you could add checks to see if a pop-up box exists and if the mouse location is within it - then skip processing the movement command.

That or you can patch the source engine if you are using the full version.
#3
07/16/2012 (12:54 pm)
Thanks guys, I'll take a look at both. For now the easy fix was the global $dialogOpen = true; and then put if($dialogOpen) in my tooltip's onMouseEnter and movement onMouseUp behavior scripts. I can see this is a hack, but for now works pretty well with some minor tweaks.

Another option is that GUI components by default, even in your mainScreen GUI if set visible=true are modal and block all mouse events by default. This would allow putting the character portrait, inventory, and loot windows in the mainScreen gui component and having instant functionalty.