I'm not sure if this is a feature, or a bug (heaven forbid!), or I'm doing something stupid.
I have several StringGadget() in a row, created in a loop and the TAB key order lets me move back and fore between them.
If I write the program using the conventional PB EventMangement style all works well and I can skip some StringGadgets (In the real application the program completes them for me, but the user can edit them if wanted.) The cursor ends up where I want it.
If I write the program using BindGadgetEvent() to acheive the same effect I can still skip some StringGadgets but the cursor does not appear in the StringGadget I have jumped to even though keyboard input does go to the gadget.
Here are my simplified examples... I would much rather make the BindGadgetEvent() method work as a whole lot of other things become easier for me.
Any comments welcomed.
RichardL
Code: Select all
; PB5.44LTS + Windows10
; Version 1 using normal event management
; =======================================
; Make display
OpenWindow(0, 0, 0, 500, 140, "Set StringGadget Test. Use TAB key to progress...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
X = 5
For n = 1 To 8
StringGadget (n, X, 10, 50, 20, Str(n))
X+55
Next
SetActiveGadget(4) ; Start at #4.... See CURSOR OK
; Event manager
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 6
If EventType() = #PB_EventType_LostFocus
SetActiveGadget(2) ; Jumps to #2... See CURSOR OK
EndIf
EndSelect
EndSelect
ForEver
Code: Select all
; Version 2 using BindGadgetEvent()
; =================================
Declare Stringin()
OpenWindow(0, 0, 0, 500, 140, "Set StringGadget Test. Use TAB key to progress...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
X = 5
For n = 1 To 8
StringGadget (n, X, 10, 50, 20, Str(n))
BindGadgetEvent(n,@Stringin()) ; Disable this line and un-comment the event mangager stuff.
X+55
Next
SetActiveGadget(4) ; Start at #4.... See CURSOR OK
; Event manager
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
EndSelect
ForEver
Procedure Stringin() ; Here when Get/Lost focus or content Changes
; When we get to #6 jump back to #2 (#1,#7 and #8 filled in automatically)
If EventGadget() = 6
If EventType() = #PB_EventType_LostFocus
SetActiveGadget(2) ; Jumps to #2... but NO CURSOR!
EndIf
EndIf
EndProcedure