PDA

View Full Version : onTab for numbercontrols?



Moon Wizard
May 17th, 2009, 22:08
Has anybody figured out how to capture onTab events for numbercontrols?

Both string and number controls support tabbing, but only stringcontrol appears to allow the onTab event to be captured.

I have a window with fields that change depending on a radio button setting. This means that hard-coded tabtargets will not work for this case. I can capture the tab key on stringcontrols to allow dynamic tab targeting, but any numbercontrol breaks the system.

The other options I'm considering are to replace numbercontrols with stringcontrols (and try to handle fallout), or to try using subwindows for each radio option.

Thanks,
JPG

Bidmaron
May 18th, 2009, 03:29
Well, I started to recommend this thread (https://www.fantasygrounds.com/forums/showthread.php?t=9997&highlight=ontab+numbercontrol), but I see you were a party to it. Joshuha's idea of an invisible dispatch control seemed to me to be the most promising idea.

Foen
May 18th, 2009, 06:26
Hi JPG

This is a serious gap in numbercontrol functionality which makes dynamic windoclasses very difficult to program. Another way around it (which may be eaiser than the other two options) is to place a hidden stringcontrol next in the tab order from your numbercontrol, and dynamically set the target from the stringcontrol's onGainFocus event handler:

mynumcontrol has its tabnext pointing to mynumcontrol_next (hidden stringcontrol)
the onGainFocus of mynumcontrol_next is invoked when you tab out of mynumcontrol
the event handler calls targetcontrol.setFocus()

The last step can be changed dynamically to reflect changes in the window contents. Unfortunately, you have to repeat the process with a distinct hidden control (mynumcontrol_prev) if you also want to tab backwards (yuck!).

Stuart