Game Development Community

Using tab to navigate a gui

by Demolishun · in Torque Game Engine · 03/18/2007 (3:13 pm) · 2 replies

For the life of me I cannot figure this out. I want to do this:
www.garagegames.com/mg/forums/result.thread.php?qt=21049

But I cannot figure out how to get GuiButtonCtrl to respond to tabs. I have set this:
GuiButtonProfile.tab = true;
GuiButtonProfile.canKeyFocus = true;

However, they still do ignore my tab input.

Please explain from start to finish what has to happen for this to work. It is just odd. I tried this under 1.3 and could not make it work either. Not sure where I am missing something. I am assuming just pressing tab/shift-tab does this. I can see in the GUI code where tab is supposed to work: guiCanvas.cc.

Thanks,
Frank

About the author

I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67


#1
03/19/2007 (11:06 am)
You may need to set "tab" and "canKeyFocus" in the profile data.

GuiButtonProfile is defined under common/ui/defaultProfiles.cs.
It may be a better idea to create a new profile that inherits from GuiButtonProfile and set the tab properties there. Depends on if you want universal behavior for all controls using the GuiButtonProfile.

In the C++ code, look at how GuiButtonBaseCtrl::onKeyDown handles the 'return' key. You may need to add a call to onAction() if you want it to act like a mouse press. (see onMouseUp() in the same class).

Hope that helps. Good luck.
#2
03/19/2007 (6:53 pm)
That for the tip for the onAction stuff. I have learned a lot since I posted this. The code that handles this has functionality issues. One problem is the standard button does not have a visual cue when it is firstresponder. I also noticed that the code responsible for handling tabs gets called, but always returns the first control in the list and does not cycle. I do not know if this is the behavior of 1.3, but 1.5 is what I am talking about. My code requires changes beyond the scope of this original post and once I get it nailed down I will generate a resource covering my adaption.

I think I figured out the issues so far. One problem found is that the call "last()" does not return what I expected. Which is why I think the tabnext() and tabprev() calls may have issues. I am currently reworking that call in the canvas widget by creating a new version of each. I am roughly modeling it after the tabbed window container.

The above script that modifies the common/ui definition (thanks for telling where that is BTW, I could not find it!) works, it was just the underlying functions did not seem to work right.

Here are some changes I am working on:
1. Ability to assign events to GUI specific events. This is important for devices like gamepads. This uses a custom map that is unrelated to the actionmap. I think at some point the entire GUI should be updated to respond to actionmap events specific to the GUI, but that is going to take a lot of work. For now I am going to create a simple mapping scheme just for the canvas and some button widgets.
2. Fixing some of the tabbing stuff in the canvas widget and extending the functionality to use my new mapping stuff.
3. A way to map all inputs for in the simulation. Right now it is missing mapping for analog inputs. This is a simple fix and so I will add it.

One peeve I have had with games in general is the lack of customization for experimenting with alternate input devices. Descent 1 had an excellent mapping system and I used to map thinks like power glove flex strips to control the ship by bending my fingers. A lot of fun. Games that are so rigid to not provide flexibility are inexcusable. If a game fails because the control mapping is bad and cannot be changed then that is just stupid and preventable.

Okay, big rant, but hopefully will save some else time.

Thanks for your help Randy,
Frank