PDA

View Full Version : Tabbing and invisible fields



Moon Wizard
March 28th, 2009, 00:40
There are several windows in the 4E_JPG ruleset where the view on a page changes based on the value of a radio button. (i.e. Items can be of type Weapon, Armor or Other) The fields displayed on the items sheet vary depending on which radio button is selected.

The easiest way to accomplish this was through the use of the setVisible command to hide/show the appropriate fields when the radio button value is changed.

However, when setting up the tab order in the XML, you can only specify one field as the target for prev/next tab. When fields are hidden, they can still be tabbed to, even though you can't see them gain focus. This makes editing of pages with dynamic hidden fields to be challenging.

Has anybody figured out how to get tabbing to work around hidden fields?

I was thinking that I could build a custom tab mapping in the window class, and just pass the individual onTab events to the parent window. However, the numbercontrol field does not support the onTab callback. Also, the onGainFocus callback is not supported either, so no way to determine if it gets focus while invisible.

Thanks,
JPG

PneumaPilot
March 28th, 2009, 02:52
Is there a way that you could have the control detect when it becomes the active control (has been tabbed to), then check for isVisible, and if not, pass the tab along to the next one where the test is repeated?

Moon Wizard
March 28th, 2009, 03:10
For stringcontrols, I believe you can use onGainFocus, onTab and/or isVisible to accomplish this.

However, numbercontrols have no corresponding callbacks for gaining focus or intercepting keystrokes (including tabs).

JPG

Foen
March 28th, 2009, 07:34
This is a problem, especially when using numbercontrols, and I ended up adding invisible stringcontrols as 'bounce' fields when I needed to capture onTab events.

If you want to tab forward out of a numbercontrol and select the tabtarget dynamically, then set the tab order to point to the bounce control, capture the onGainFocus event and reset the focus to the dynamic target.

Horrible, like most work-arounds, but it works.

Stuart

joshuha
March 28th, 2009, 13:51
I know it would be a big rewrite but numbercontrols do support setFocus right? Rather than individual stringcontrols to cover just the number controls couldn't we have one master stringcontrol that is the ONLY tabbed control. Then as it recieves the onTab events it intelligently handles the previous control and has logic then to call a setFocus on the appropriate control? I imagine you would try to set it up as generic as possible so you could pass it a LUA table for different controls for different tab "states". Then each control would self determine if it hasFocus() so this new handler would always no what has focus so it can determine what should have focus on a tab.

Moon Wizard
March 28th, 2009, 20:01
Both good ideas. The other option I was thinking might work would be to use subwindows, but my experience with them so far has been mixed.

Thanks for the ideas,
JPG