Popping dialogs
by John Coyne · in Torque Game Builder · 03/09/2006 (4:43 am) · 4 replies
Hi
For my game i'd like to have the user left click the scene and have a small menu pop up at the clicked location. The user then chooses what to drop at this location or closes the menu. I've looked around and it seems what I have to do is use "canvas.pushDialog(dialogue)". I've tried this and get an "invalid control" message. Is a dialoge the same as any other GUI in torque? Cos I just made a small menu, also, is there a way to pop the dialoge on screen at the click?
So far this is looking like it might be easier to build a custom menu object instead.
ps. I assume I have to load the menu at some point place in the code. I cant seem to find any info on that either.
For my game i'd like to have the user left click the scene and have a small menu pop up at the clicked location. The user then chooses what to drop at this location or closes the menu. I've looked around and it seems what I have to do is use "canvas.pushDialog(dialogue)". I've tried this and get an "invalid control" message. Is a dialoge the same as any other GUI in torque? Cos I just made a small menu, also, is there a way to pop the dialoge on screen at the click?
So far this is looking like it might be easier to build a custom menu object instead.
ps. I assume I have to load the menu at some point place in the code. I cant seem to find any info on that either.
About the author
#2
03/09/2006 (11:03 am)
You may find that when you've pushed the new gui its taken over handling of mouse events.
#3
03/14/2006 (5:19 am)
Ah, hadnt though of that. Thanks, I'll have another go at this today.
#4
Another solution would be to add() the new gui to the existing gui so it becomes a part of it (doesn't take all the mouse events if you make sure what you add isn't the entire screen), then you can simply remove() it from the gui.
03/14/2006 (10:57 pm)
You can set "modal = false;" in the profile to prevent it from taking mouse events (Gary is right it is probably taking the mouse events). I beleive there arlready is a "modeless" gui profile.Another solution would be to add() the new gui to the existing gui so it becomes a part of it (doesn't take all the mouse events if you make sure what you add isn't the entire screen), then you can simply remove() it from the gui.
Torque Owner John Coyne
function SceneWindow2D::onMouseDown(%this, %modifier, %worldPos, %mouseClicks) { echo("Left mouse click at " @ %worldPos); canvas.popDialog(GuiShell); } function SceneWindow2D::onRightMouseDown(%this, %modifier, %worldPos, %mouseClicks) { if(GuiShell.isAwake()) { echo("Popping dialog off the screen"); canvas.popDialog(GuiShell); } else { echo("Pushing dialog onto the screen"); canvas.pushDialog(GuiShell); GuiShell.setPosition(getWord(%worldPos, 0), getWord(%worldPos, 1)); } }