Stumped
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Code: Select all
Enumeration
#STR_EditCtrl1
#STR_EditCtrl2
#STR_EditCtrl3
#STR_EditCtrl4
#BTN_Untitled1
EndEnumeration
#IDM_ReturnKey = 101
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
StringGadget(#STR_EditCtrl1,5,5,250,20,"untitled1")
StringGadget(#STR_EditCtrl2,5,35,250,20,"untitled2")
StringGadget(#STR_EditCtrl3,5,65,250,20,"untitled3")
StringGadget(#STR_EditCtrl4,5,90,250,20,"untitled4")
ButtonGadget(#BTN_Untitled1,5,120,120,25,"untiled")
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
If EventType() = #PB_EventType_Focus And EventGadget() >= #STR_EditCtrl1 And EventGadget() < #STR_EditCtrl4
AddKeyboardShortcut(0,#PB_Shortcut_Return,#IDM_ReturnKey)
Else
RemoveKeyboardShortcut(0,#PB_Shortcut_Return)
EndIf
EndIf
If EventID = #PB_Event_Menu
Index = GetActiveGadget()
If Index = #STR_EditCtrl4
SetActiveGadget(#STR_EditCtrl1)
Else
SetActiveGadget(Index + 1)
EndIf
EndIf
Until EventID = #PB_Event_CloseWindowWindows 10 Pro, 64-Bit / Whose Hoff is it anyway?
If you don't mind some api then this puts the cursor at the end of the string input when tabbing, seems more natural.
Code: Select all
Enumeration
#STR_EditCtrl1
#STR_EditCtrl2
#STR_EditCtrl3
#STR_EditCtrl4
EndEnumeration
#IDM_ReturnKey = 101
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
StringGadget(#STR_EditCtrl1,5,5,250,20,"untitled1")
StringGadget(#STR_EditCtrl2,5,35,250,20,"untitled2")
StringGadget(#STR_EditCtrl3,5,65,250,20,"untitled3")
StringGadget(#STR_EditCtrl4,5,90,250,20,"untitled4")
AddKeyboardShortcut(0,#PB_Shortcut_Return,#IDM_ReturnKey)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Menu
Index = GetActiveGadget()
If Index = #STR_EditCtrl4
SetActiveGadget(#STR_EditCtrl1)
Else
SetActiveGadget(Index + 1)
EndIf
l=Len(GetGadgetText(GetActiveGadget()))
SendMessage_(GadgetID(GetActiveGadget()),#EM_SETSEL,l,l)
EndIf
Until EventID = #PB_Event_CloseWindow
Thanks guys works fine 
I knew there had to be a simple way....
Strangly tho when I add , #PB_String_Numeric to the end for non-text input it stops working?
is this a normal action or a bug?
(update: it doesnt work after you entered any values in
have to tab to next box)
Basically this is reading input from a barcode reader which automatically put's a CR/LF after reading the barcode, and i needed it to goto the next box/gadget after.
TIA
TM.
I knew there had to be a simple way....
Strangly tho when I add , #PB_String_Numeric to the end for non-text input it stops working?
is this a normal action or a bug?
(update: it doesnt work after you entered any values in
Basically this is reading input from a barcode reader which automatically put's a CR/LF after reading the barcode, and i needed it to goto the next box/gadget after.
TIA
TM.
Heres my version (including bugfix) :
Edited : example is now more bulletproof
Code: Select all
Enumeration
#STR_EditCtrl1
#STR_EditCtrl2
#STR_EditCtrl3
#STR_EditCtrl4
#BTN_Untitled1
#STR_EditCtrl5
EndEnumeration
#IDM_ReturnKey = 101
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
StringGadget(#STR_EditCtrl1,5,5,250,20,"untitled1",#PB_String_Numeric)
StringGadget(#STR_EditCtrl2,5,35,250,20,"untitled2",#PB_String_Numeric)
StringGadget(#STR_EditCtrl3,5,65,250,20,"untitled3",#PB_String_Numeric)
StringGadget(#STR_EditCtrl4,5,90,250,20,"untitled4",#PB_String_Numeric)
ButtonGadget(#BTN_Untitled1,5,120,120,25,"untiled",#PB_String_Numeric)
StringGadget(#STR_EditCtrl5,5,155,250,20,"untitled5")
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
If EventType() = #PB_EventType_Focus And GadgetType(EventGadget())=#PB_GadgetType_String
AddKeyboardShortcut(0,#PB_Shortcut_Return,#IDM_ReturnKey)
Debug "AddKeyboardShortcut"
ElseIf EventType() = #PB_EventType_LostFocus And GadgetType(EventGadget())=#PB_GadgetType_String
RemoveKeyboardShortcut(0,#PB_Shortcut_Return)
Debug "RemoveKeyboardShortcut"
EndIf
EndIf
If EventID = #PB_Event_Menu And EventMenu()=#IDM_ReturnKey
Index = GetActiveGadget()
If Index = #STR_EditCtrl4
SetActiveGadget(#STR_EditCtrl1)
ElseIf IsGadget(Index + 1)
SetActiveGadget(Index + 1)
EndIf
EndIf
Until EventID = #PB_Event_CloseWindow
Last edited by ABBKlaus on Wed Mar 12, 2008 2:54 pm, edited 1 time in total.
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
There wasn't anything to bugfix until you changed it.ABBKlaus wrote:Heres my version (including bugfix) :
First you don't need to asign #PB_String_Numeric to a button and second the code fails if you add another StringGadget() because you removed the ID range check.
@Tech-Man:
Use my original version and add your flags and you're good to go:
Code: Select all
Enumeration
#STR_EditCtrl1
#STR_EditCtrl2
#STR_EditCtrl3
#STR_EditCtrl4
#BTN_Untitled1
#STR_EditCtrl5
EndEnumeration
#IDM_ReturnKey = 101
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
StringGadget(#STR_EditCtrl1,5,5,250,20,"untitled1",#PB_String_Numeric)
StringGadget(#STR_EditCtrl2,5,35,250,20,"untitled2",#PB_String_Numeric)
StringGadget(#STR_EditCtrl3,5,65,250,20,"untitled3",#PB_String_Numeric)
StringGadget(#STR_EditCtrl4,5,90,250,20,"untitled4",#PB_String_Numeric)
ButtonGadget(#BTN_Untitled1,5,120,120,25,"untiled")
StringGadget(#STR_EditCtrl5,5,150,250,25,"untiled5",#PB_String_Numeric)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
If EventType() = #PB_EventType_Focus And EventGadget() >= #STR_EditCtrl1 And EventGadget() <= #STR_EditCtrl4
AddKeyboardShortcut(0,#PB_Shortcut_Return,#IDM_ReturnKey)
ElseIf EventType() = #PB_EventType_LostFocus
RemoveKeyboardShortcut(0,#PB_Shortcut_Return)
EndIf
EndIf
If EventID = #PB_Event_Menu And EventMenu() = #IDM_ReturnKey
Index = GetActiveGadget()
If Index = #STR_EditCtrl4
SetActiveGadget(#STR_EditCtrl1)
Else
SetActiveGadget(Index + 1)
EndIf
EndIf
Until EventID = #PB_Event_CloseWindow
Last edited by Fluid Byte on Wed Mar 12, 2008 3:05 pm, edited 1 time in total.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Can't confirm that, it's working flawlessly here (WindowsXP SP2 / PB4.20b).ABBKlaus wrote:Your code is not working fluidYou are removing the keyboard shortcut too early.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
You're right, Klaus
you can even read it from the code only:
removing the shortcut on any not special gadget event.
it cannot work at all.
additionally, not a single keytype is accepted by any gadget.
you can even read it from the code only:
Code: Select all
If EventID = #PB_Event_Gadget
If EventType() =
AddKeyboardShortcut(0,#PB_Shortcut_Return,#IDM_ReturnKey)
Else
;*****************************************
RemoveKeyboardShortcut(0,#PB_Shortcut_Return)
;*****************************************
EndIf
EndIf it cannot work at all.
additionally, not a single keytype is accepted by any gadget.
oh... and have a nice day.
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Ok, now I see what you mean. You just need to check for #PB_EventType_LostFocus and it's working again. Nevertheless you shouldn't remove the ID range check.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
