Game Development Community

make GuiControl objects respond to mouse click?

by Sean Xie · in Torque 2D Beginner · 02/03/2014 (1:03 pm) · 5 replies

I am having trouble making GuiControl respond to mouse click.
It seems that only SceneWindow objects can respond to mouse clicks.
How do I make other GuiControl objects do the same thing?

#1
02/03/2014 (1:39 pm)
Make sure the profile assigned to the GuiControl has the Modal field set to true.
#2
02/05/2014 (2:14 pm)
I'm sure that the profile has the modal field set to true.

The scenario is, I'm making an item inventory in my game using GuiControl. Each item displayed on the screen is a GuiSpriteCtrl. But as I click on an item, it does not seem to respond to the mouse click (neither onTouchDown() nor onMouseDown() works).

Is GuiSpriteCtrl the right way to go in this case or is there a more preferable way to display the items?
#3
02/05/2014 (6:50 pm)
https://github.com/RichardRanft/Torque2D.git - pull the inventory branch and take a look.
#4
02/05/2014 (7:42 pm)
Thank you so much, Richard.

I think this is a great solution to my problem.
#5
02/21/2014 (12:16 pm)
So I tried the inventory module and I noticed that there is a small bug.

When you click on the corner of an item in the inventory, you can copy that item as you release the item.