Expanding on @boddhi's example, the tab order can be arranged as required:
Code: Select all
#stringTab = 99
window = OpenWindow(#PB_Any, 0, 0, 590, 220, "Textbox Tab Order",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; sequential order
s1 = StringGadget(#PB_Any, 30, 30, 150, 30, "1. first tab")
s2 = StringGadget(#PB_Any, 220, 30, 150, 30, "2. second tab")
s3 = StringGadget(#PB_Any, 410, 30, 150, 30, "3. third tab")
; reverse order
s4 = StringGadget(#PB_Any, 30, 90, 150, 30, "6. sixth tab ")
s5 = StringGadget(#PB_Any, 220, 90, 150, 30, "5. fifth tab")
s6 = StringGadget(#PB_Any, 410, 90, 150, 30, "4. fourth tab")
; sequential order
s7 = StringGadget(#PB_Any, 30, 150, 150, 30, "7. seventh tab")
s8 = StringGadget(#PB_Any, 220, 150, 150, 30, "8. eighth tab")
s9 = StringGadget(#PB_Any, 410, 150, 150, 30, "9. ninth tab")
AddKeyboardShortcut(window ,#PB_Shortcut_Tab, #stringTab)
SetGadgetData(s1, s2) ; from string 1 jump to string 2
SetGadgetData(s2, s3) ; from string 2 jump to string 3
SetGadgetData(s3, s6) ; from string 3 jump to string 6
SetGadgetData(s4, s7) ; from string 4 jump to string 7
SetGadgetData(s5, s4) ; from string 5 jump to string 4
SetGadgetData(s6, s5) ; from string 6 jump to string 5
SetGadgetData(s7, s8) ; from string 7 jump to string 8
SetGadgetData(s8, s9) ; from string 8 jump to string 9
SetGadgetData(s9, s1) ; from string 9 jump to string 1
SetActiveGadget(s1)
Repeat
event= WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Menu
Select EventMenu()
Case #stringTab
nextTab = GetGadgetData(GetActiveGadget())
SetActiveGadget(nextTab)
EndSelect
EndSelect
Until appQuit
And here, in a different order:
Code: Select all
#stringTab = 99
window = OpenWindow(#PB_Any, 0, 0, 590, 220, "Textbox Tab Order",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
s1 = StringGadget(#PB_Any, 30, 30, 150, 30, "1. first tab")
s2 = StringGadget(#PB_Any, 220, 30, 150, 30, "6. sixth tab ")
s3 = StringGadget(#PB_Any, 410, 30, 150, 30, "7. seventh tab")
s4 = StringGadget(#PB_Any, 30, 90, 150, 30, "2. second tab")
s5 = StringGadget(#PB_Any, 220, 90, 150, 30, "5. fifth tab")
s6 = StringGadget(#PB_Any, 410, 90, 150, 30, "8. eighth tab")
s7 = StringGadget(#PB_Any, 30, 150, 150, 30, "3. third tab")
s8 = StringGadget(#PB_Any, 220, 150, 150, 30, "4. fourth tab")
s9 = StringGadget(#PB_Any, 410, 150, 150, 30, "9. ninth tab")
AddKeyboardShortcut(window ,#PB_Shortcut_Tab, #stringTab)
SetGadgetData(s1, s4) ; from string 1 jump to string 4
SetGadgetData(s2, s3) ; from string 2 jump to string 3
SetGadgetData(s3, s6) ; from string 3 jump to string 6
SetGadgetData(s4, s7) ; from string 4 jump to string 7
SetGadgetData(s5, s2) ; from string 5 jump to string 2
SetGadgetData(s6, s9) ; from string 6 jump to string 9
SetGadgetData(s7, s8) ; from string 7 jump to string 8
SetGadgetData(s8, s5) ; from string 8 jump to string 5
SetGadgetData(s9, s1) ; from string 9 jump to string 1
SetActiveGadget(s1)
Repeat
event= WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Menu
Select EventMenu()
Case #stringTab
nextTab = GetGadgetData(GetActiveGadget())
SetActiveGadget(nextTab)
EndSelect
EndSelect
Until appQuit
And here, with reverse tabbing using the
Shift-Tab key combination:
Code: Select all
#stringTabForward = 98
#stringTabBackward = 99
Dim tabs(9, 1)
window = OpenWindow(#PB_Any, 0, 0, 590, 220, "Textbox Tab Order",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(1, 30, 30, 150, 30, "1. first tab")
StringGadget(2, 220, 30, 150, 30, "2. second tab")
StringGadget(3, 410, 30, 150, 30, "3. third tab")
StringGadget(4, 30, 90, 150, 30, "6. sixth tab ")
StringGadget(5, 220, 90, 150, 30, "5. fifth tab")
StringGadget(6, 410, 90, 150, 30, "4. fourth tab")
StringGadget(7, 30, 150, 150, 30, "7. seventh tab")
StringGadget(8, 220, 150, 150, 30, "8. eighth tab")
StringGadget(9, 410, 150, 150, 30, "9. ninth tab")
AddKeyboardShortcut(window ,#PB_Shortcut_Tab, #stringTabForward)
AddKeyboardShortcut(window ,#PB_Shortcut_Shift | #PB_Shortcut_Tab, #stringTabBackward)
tabs(1, 0) = 2 : tabs(1, 1) = 9 ; string 1 forwards to string 2 and reverses to string 9
tabs(2, 0) = 3 : tabs(2, 1) = 1 ; string 2 forwards to string 3 and reverses to string 1
tabs(3, 0) = 6 : tabs(3, 1) = 2 ; string 3 forwards to string 6 and reverses to string 2
tabs(4, 0) = 7 : tabs(4, 1) = 5 ; string 4 forwards to string 7 and reverses to string 5
tabs(5, 0) = 4 : tabs(5, 1) = 6 ; string 5 forwards to string 4 and reverses to string 6
tabs(6, 0) = 5 : tabs(6, 1) = 3 ; string 6 forwards to string 5 and reverses to string 3
tabs(7, 0) = 8 : tabs(7, 1) = 4 ; string 7 forwards to string 8 and reverses to string 4
tabs(8, 0) = 9 : tabs(8, 1) = 7 ; string 8 forwards to string 9 and reverses to string 7
tabs(9, 0) = 1 : tabs(9, 1) = 8 ; string 9 forwards to string 1 and reverses to string 8
SetActiveGadget(1)
Repeat
event= WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Menu
Select EventMenu()
Case #stringTabForward
nextTab = tabs(GetActiveGadget(), 0)
SetActiveGadget(nextTab)
Case #stringTabBackward
prevTab = tabs(GetActiveGadget(), 1)
SetActiveGadget(prevTab)
EndSelect
EndSelect
Until appQuit