EDITOR GADGET and TAB key
EDITOR GADGET and TAB key
I have build the window which has a few editor gadgets.
How to move between editor gadgets with keyboard ? (TAB makes own moves inside the editor gadget). Reverse move is possible: TAB + SHIFT.
How to move between editor gadgets with keyboard ? (TAB makes own moves inside the editor gadget). Reverse move is possible: TAB + SHIFT.
- Hroudtwolf
- Addict

- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
- Contact:
Yes Hrudtwolf. Here is the simple code, impleament please:
Code: Select all
;-Window Constants
Enumeration 1
#Window_Form1
EndEnumeration
;-Gadget Constants
Enumeration 1
#Gadget_Form1_Text0
#Gadget_Form1_Editor1
#Gadget_Form1_Editor2
#Gadget_Form1_Option3
#Gadget_Form1_Option4
#Gadget_Form1_String5
#Gadget_Form1_String6
#Gadget_Form1_String7
#Gadget_Form1_Button8
EndEnumeration
Procedure.l Window_Form1()
If OpenWindow(#Window_Form1,176,92,400,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible,"How to use TAB key with editor")
If CreateGadgetList(WindowID(#Window_Form1))
TextGadget(#Gadget_Form1_Text0,0,7,395,15,"Move the cursor wit TAB key between gadgets",#PB_Text_Center)
EditorGadget(#Gadget_Form1_Editor1,50,25,300,75)
EditorGadget(#Gadget_Form1_Editor2,50,110,300,60)
OptionGadget(#Gadget_Form1_Option3,55,180,80,15,"Option9")
OptionGadget(#Gadget_Form1_Option4,270,180,80,15,"Option10")
StringGadget(#Gadget_Form1_String5,55,210,80,25,"")
StringGadget(#Gadget_Form1_String6,160,210,80,25,"")
StringGadget(#Gadget_Form1_String7,270,210,80,25,"")
ButtonGadget(#Gadget_Form1_Button8,175,265,60,25,"EXIT")
HideWindow(#Window_Form1,0)
ProcedureReturn WindowID()
EndIf
EndIf
EndProcedure
;-Main Loop
If Window_Form1()
quitForm1=0
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenuID()
GadgetID =EventGadgetID()
WindowID =EventWindowID()
Select EventID
Case #PB_Event_CloseWindow
If WindowID=#Window_Form1
quitForm1=1
EndIf
Case #PB_Event_Gadget
Select GadgetID
Case #Gadget_Form1_Editor1
Case #Gadget_Form1_Editor2
Case #Gadget_Form1_Option3
Case #Gadget_Form1_Option4
Case #Gadget_Form1_String5
Case #Gadget_Form1_String6
Case #Gadget_Form1_String7
Case #Gadget_Form1_Button8
EndSelect
EndSelect
Until quitForm1
CloseWindow(#Window_Form1)
EndIf
End
Coded for PB4 Beta7 so you'll need to change the OpenWindow() parameters for use in PB3.94. 
Code: Select all
;-Window Constants
Enumeration 1
#Window_Form1
EndEnumeration
;-Gadget Constants
Enumeration 1
#Gadget_Form1_Text0
#Gadget_Form1_Editor1
#Gadget_Form1_Editor2
#Gadget_Form1_Option3
#Gadget_Form1_Option4
#Gadget_Form1_String5
#Gadget_Form1_String6
#Gadget_Form1_String7
#Gadget_Form1_Button8
EndEnumeration
Procedure WinCallback(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
Select *pnmhdr\code
Case #EN_MSGFILTER
*pMSGFILTER.MSGFILTER = lParam
If *pMSGFILTER\wParam = #VK_TAB And *pMSGFILTER\msg <> #WM_KEYUP
Select *pnmhdr\hwndFrom
Case GadgetID(#Gadget_Form1_Editor1)
SetActiveGadget(#Gadget_Form1_Editor2)
; --> Return non-zero to ignore the Tab key
result = 1
Case GadgetID(#Gadget_Form1_Editor2)
SetActiveGadget(#Gadget_Form1_Option3)
; --> Return non-zero to ignore the Tab key
result = 1
EndSelect
EndIf
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
Procedure.l Window_Form1()
If OpenWindow(#Window_Form1,176,92,400,300,"How to use TAB key with editor",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
If CreateGadgetList(WindowID(#Window_Form1))
TextGadget(#Gadget_Form1_Text0,0,7,395,15,"Move the cursor wit TAB key between gadgets",#PB_Text_Center)
EditorGadget(#Gadget_Form1_Editor1,50,25,300,75)
EditorGadget(#Gadget_Form1_Editor2,50,110,300,60)
;...Tell the EditorGadgets we want ot filter keyboard messages
;...We catch the events in the #WM_NOTIFY msg in our CallBack procedure
SendMessage_(GadgetID(#Gadget_Form1_Editor1), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
SendMessage_(GadgetID(#Gadget_Form1_Editor2), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
OptionGadget(#Gadget_Form1_Option3,55,180,80,15,"Option9")
OptionGadget(#Gadget_Form1_Option4,270,180,80,15,"Option10")
StringGadget(#Gadget_Form1_String5,55,210,80,25,"")
StringGadget(#Gadget_Form1_String6,160,210,80,25,"")
StringGadget(#Gadget_Form1_String7,270,210,80,25,"")
ButtonGadget(#Gadget_Form1_Button8,175,265,60,25,"EXIT")
HideWindow(#Window_Form1,0)
;...Window callback is where we catch tab key events from our EditorGadget
SetWindowCallback(@WinCallback())
ProcedureReturn WindowID(#Window_Form1)
EndIf
EndIf
EndProcedure
;-Main Loop
If Window_Form1()
quitForm1=0
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
Select EventID
Case #PB_Event_CloseWindow
If WindowID=#Window_Form1
quitForm1=1
EndIf
Case #PB_Event_Gadget
Select GadgetID
Case #Gadget_Form1_Editor1
Case #Gadget_Form1_Editor2
Case #Gadget_Form1_Option3
Case #Gadget_Form1_Option4
Case #Gadget_Form1_String5
Case #Gadget_Form1_String6
Case #Gadget_Form1_String7
Case #Gadget_Form1_Button8
EndSelect
EndSelect
Until quitForm1
CloseWindow(#Window_Form1)
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
yeah, it's on my wishlist as well, and i've been struggling with this subject as well (do a search on the forum
)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
> it's on my wishlist as well
In the past, a lot of people were asking for the EditorGadget to actually act
this way, instead of TAB switching to the next gadget. For example:
http://www.purebasic.fr/english/viewtop ... 9&start=15
So then Fred happily changed it in v3.93 according to all the wishes:
Fixed: TAB in an EditorGadget() doesn't give the focus to others gadgets anymore but insert a Tab
And now people want it to work the old way again? :roll: Give Fred a break.
In the past, a lot of people were asking for the EditorGadget to actually act
this way, instead of TAB switching to the next gadget. For example:
http://www.purebasic.fr/english/viewtop ... 9&start=15
So then Fred happily changed it in v3.93 according to all the wishes:
Fixed: TAB in an EditorGadget() doesn't give the focus to others gadgets anymore but insert a Tab
And now people want it to work the old way again? :roll: Give Fred a break.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Michael Vogel
- Addict

- Posts: 2823
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Ua - why people don't accept (sometimes bad) standards?
#WS_TABSTOP has been defined in windows for sich things. Again a lot of work to simulate a windows like behaviour with PureBasic (and I thought, the keyboard handling for shortcuts - "Ok" - within dialogs is the only difference to real windows programs)
Also in windows it is/was possible to enter a tab (and even a crlf) within an edit field - so what users asked for going away from the (windows) standard?
__________________
So one additional pull-up to get more windows-like behaviour...
#WS_TABSTOP has been defined in windows for sich things. Again a lot of work to simulate a windows like behaviour with PureBasic (and I thought, the keyboard handling for shortcuts - "Ok" - within dialogs is the only difference to real windows programs)
Also in windows it is/was possible to enter a tab (and even a crlf) within an edit field - so what users asked for going away from the (windows) standard?
__________________
So one additional pull-up to get more windows-like behaviour...
Code: Select all
If *pMSGFILTER\wParam = #VK_TAB And *pMSGFILTER\msg <> #WM_KEYUP And (GetKeyState_(#VK_CONTROL)&$80)=0
