Page 1 of 1
How to use Tab to go to next Gadget?
Posted: Sat Oct 08, 2011 8:04 pm
by Nexus100
Hi Digital Maniacs
firstly as usual many thanks in advance!
Can anyone help me with this: I want the following;
If user types info into a text gadget and then presses TAB I want focus to change to the next gadget.
This seems to work from text gadget to text gadget, but on the last text gadget the next gadget is a button and focus either does not go to it (gadgets are created in the correct order) Or I need to have some help with code that allows the button to show it has focus and allows the user to either click with mouse OR press <RETURN>.
Thanks again!
Re: How to use Tab to go to next Gadget?
Posted: Sun Oct 09, 2011 8:00 am
by Mr.L
Hello!
I don't know if this is the most efficient solution but i once did it like that:
Code: Select all
OpenWindow(0,0,0,400,140,"Tab-Test")
StringGadget(0,10,10,380,20,"String1")
StringGadget(1,10,40,380,20,"String2")
StringGadget(2,10,70,380,20,"String3")
ButtonGadget(3,10,100,180,30,"Button1")
ButtonGadget(4,210,100,180,30,"Button2")
AddKeyboardShortcut(0,#PB_Shortcut_Tab,0)
Repeat
Select WaitWindowEvent(50)
Case #PB_Event_CloseWindow
End
Case #PB_Event_Menu
Select GetActiveGadget()
Case 0 : SetActiveGadget(1)
Case 1 : SetActiveGadget(2)
Case 2 : SetActiveGadget(0)
Case 3 : SetActiveGadget(4)
Case 4 : SetActiveGadget(3)
EndSelect
EndSelect
ForEver
Re: How to use Tab to go to next Gadget?
Posted: Sun Oct 09, 2011 9:22 am
by ts-soft
Works without shortcuts
Code: Select all
OpenWindow(0,0,0,400,140,"Tab-Test")
StringGadget(0,10,10,380,20,"String1")
StringGadget(1,10,40,380,20,"String2")
StringGadget(2,10,70,380,20,"String3")
ButtonGadget(3,10,100,180,30,"Button1")
ButtonGadget(4,210,100,180,30,"Button2")
SetActiveGadget(0)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
SendMessage_(WindowID(0), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)
CompilerEndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
greetings - Thomas
Re: How to use Tab to go to next Gadget?
Posted: Sun Oct 09, 2011 10:11 am
by buddymatkona
ts-soft has the right idea but I can not resist adding this.
Code: Select all
OpenWindow(0,0,0,400,140,"Tab-Test")
StringGadget(0,10,10,380,20,"String1")
StringGadget(1,10,40,380,20,"String2")
StringGadget(2,10,70,380,20,"String3")
ButtonGadget(3,10,100,180,30,"Button1", #PB_Button_Default )
ButtonGadget(4,210,100,180,30,"Button2", #ES_NOHIDESEL)
MaxGadget = 4
MinGadget = 0
TabCount = MinGadget - 1
AddKeyboardShortcut(0,#PB_Shortcut_Tab,0)
Repeat
Select WaitWindowEvent(50)
Case #PB_Event_CloseWindow
End
Case #PB_Event_Menu
TabCount = TabCount + 1
If TabCount > MaxGadget
Tabcount = MinGadget
EndIf
Select TabCount
Case 0 : SetActiveGadget(0)
Case 1 : SetActiveGadget(1)
Case 2 : SetActiveGadget(2)
Case 3 : SetActiveGadget(3)
SendMessage_(WindowID(0), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)
For i = 1 To 3
SetGadgetText(3, "Click Me")
Delay (900)
SetGadgetText(3, "Button1")
Delay(700)
Next i
Case 4 : SetActiveGadget(4)
SendMessage_(WindowID(0), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)
For i = 1 To 3
SetGadgetText(4, "No, Click Me! ")
Delay (900)
SetGadgetText(4, "Button2")
Delay(700)
Next i
EndSelect
EndSelect
ForEver
Re: How to use Tab to go to next Gadget?
Posted: Sun Oct 09, 2011 3:39 pm
by Mr.L
Oh, I misunderstood the question
I thought he'd like to use the Tab-Key to cycle through the
Stringgadgets...