Game Development Community

Pop menu

by Wangxu · in Torque Game Engine · 01/14/2005 (11:02 am) · 11 replies

I want that when I click the mouse,on that postiont will pop out a menu.
Can it implement in TGE?thanks!

#1
01/15/2005 (4:39 am)
Someon can help me?
#2
01/15/2005 (6:33 am)
Please learn to speak english.
#3
01/15/2005 (8:20 am)
@Frogger, keep you opinons to yourself there is pleanty of GarageGamers who do not use English as their native language, that is no way to assist them.

@Wang: Anything is possible, it is too early in the morning for me to think about "how" to achomplish that, but it will most likely require getting the mouseevents. Try this resource or this one to Expose the mouse events. They aren't exactly what you need but it might get to started off
#4
01/15/2005 (8:48 am)
Sorry, but if English wasn't his native language, he could have spoken whatever was his, then it would have made more sense, sorry for barging in.

Wangxu, one of the best ways to figure this out is to see how, like the dialog options box pops out when its button is clicked, works by searching in some of the GUI's that already exist in torque. For that example, the way it was done can be found in mainmenugui.
#5
01/15/2005 (12:59 pm)
Wangxu please give more details... do you want a pop up to come up when you click a GUI element ? ... or when you click a 3d object, or a portion of the screen, etc :)
#7
01/15/2005 (2:02 pm)
Sorry,My English is not very good.
I just want a menu like after you right-click in Windows.
I've read "Object selection in Torque".
In fact,I've almost resolved it.But there is also a bug.Let me show it!
First I made a rightmenu.gui.

new GuiControl(DemoGui) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "800 600";
minExtent = "8 2";
visible = "1";

new GuiControl(MainCTRL) {
profile = "GuiDefaultProfile";
horizSizing = "center";
vertSizing = "center";
position = "0 0";
extent = "445 158";
minExtent = "8 2";
visible = "1";

new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "80 16";
minExtent = "8 2";
visible = "1";
command = "DemoGui.action(EXIT);";
accelerator = "return";
text = "Trad";
groupNum = "-1";
buttonType = "PushButton";
};

};
};

Then In playgui.cs
function PlayGui::onRightMouseDown(%this)
{
$mousepos=%this.getmouseposr();//this function return the click position
echo("right click"@$mousepos);
Canvas.pushDialog(DemoGui);
MainCTRL.position=$mousepos;
}

Now it works!
But,there is a bug.when you right-click,in the first time,the button can't appear on the right position----under the mouse.after that,it works well.
I've try that put "MainCTRL.position=$mousepos;" in the DemoGui::OnWake().It is no use!
#8
01/16/2005 (2:17 am)
Is anybody have this problem?
How to set the gui's position,before dispaly it?
#9
01/16/2005 (2:23 am)
When you design the GUI element set the main frame that you will add to add to the GUI as

visible = "0;


Then when you add the GUI element to the screen, set the position and then set the main frame

visible ="1";
#10
01/17/2005 (4:05 am)
Good idea,but also can't work!
I think this is a bug of the Engine !
#11
01/18/2005 (12:22 am)
Did you try calling the control's resize method to set its position?