|
Problem with Tabbing on TAB-controls Overview: Adding a TAB-control to a Form has its advantages. You can expand the available space for controls on the Form by number and size of used panes and you can group controls according to their relevance to certain topics. When testing the Form by moving from control to control using the TAB-key you will experience some strange behaviour! Though you did define the TAB-sequence of the Form, the actual TAB-sequence will not adhere to the defined sequence! Moreover, the Shift-TAB-key-sequence will not let you go backwards the same way as you went forward! What’s wrong with it?1 - the TAB-key moves focus from control A (#1 in TAB-sequence) directly to the TAB-control-pane (#10 in TAB-sequence!) - but not to control B, which would be #2 in TAB-sequence ! Note: If the TAB-control has focus, you can move between the panes with the left & right arrow keys. This is OK. 2 - If control C (#3) has focus, hitting the TAB-key will bring you back to control A (#1) - but NOT to Control D (#4) on pane 2 of the TAB-control! If you designed the TAB-control as an extension of the Form, means you didn’t have enough space on the Form but all of the controls have to be filled in by the user or at least have to be seen, then this behaviour is a bit of a harsh surprise. 3 - The behaviour of the Shift-TAB-key is even worse. From control B (#2) a Shift-TAB never moves back to the TAB-control (#10) as one would expect it to do but chooses to go down to control C (#3) ! Download the small demo-project for your convenience, put file into \My Projects\WD14TabControl1 - directory and unzip by doubleclick (Win7 + WinVista):WD14_TABCONTROL_PROBLEM_DEMO.zip 1 - First attempt of a fixIt seems to be very easy at first: Just capture the pressed TAB-key and decide by inspecting the Shift-key status on going up or down the TAB-sequence. Each and every control on the Form has to get a few lines of code in the Exit code. This is an example for control EditF. IF KeyPressed(VK_TAB) THEN IF KeyPressed(kpShift) THEN ReturnToCapture(EditE) ELSE ReturnToCapture(EditG) ENDEND First success: now the TAB-key works exactly as expected, the focus walks forward through the TAB-control in the correct way. Still weird: the Shift-TAB-key takes strange ways of its own, happily ignoring the commands in the exit code. The code above in fact moves the focus to EditA and not to EditE as the command says AND at the same time the TAB-control is switched and shows Pane 1. No command for that either! 2 - Refining the first fixAll experiments with setting the Tab-control to the needed Pane by Tab1 = 2, using SetFocus(..) and ScreenFirst(..) instead of ReturnToCapture(..), or using SendKey(..) - all that didn’t work. The Shift-TAB stubbornly moved focus to EditA instead of to EditE !! The solution to the problem is a button outside of the window with ReturnToCapture(EditE) in its click code and executing the button from the exit code of the control EditF by ExecuteProcess(..) ! Download the small demo-project for your convenience, put file into \My Projects\WD14TabControl2 - directory and unzip by doubleclick (Win7 + WinVista):WD14_TABCONTROL_SOLUTION.zip |