Preventing use of tab key in EditorGadget
-
- User
- Posts: 27
- Joined: Sat Oct 16, 2004 1:25 pm
Preventing use of tab key in EditorGadget
Hi,
Just a quick question. When someone presses the tab key I want to activate the next gadget and prevent the creation of a paragraph indent in the previous editor gadget.
I can activate the next gadget by pressing the tab key in the editor gadget but can't prevent the creation of an indent in the editor gadget. I tried using:
keybd_event_(#VK_BACK, 0 , 0 , 0)
keybd_event_(#VK_BACK, 0, #KEYEVENTF_KEYUP, 0)
to remove the indent but this doesn't work. Any suggestions?
Just a quick question. When someone presses the tab key I want to activate the next gadget and prevent the creation of a paragraph indent in the previous editor gadget.
I can activate the next gadget by pressing the tab key in the editor gadget but can't prevent the creation of an indent in the editor gadget. I tried using:
keybd_event_(#VK_BACK, 0 , 0 , 0)
keybd_event_(#VK_BACK, 0, #KEYEVENTF_KEYUP, 0)
to remove the indent but this doesn't work. Any suggestions?
See if this works for you...
viewtopic.php?t=14414&highlight=editorgadget+tab
viewtopic.php?t=14414&highlight=editorgadget+tab
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
-
- User
- Posts: 27
- Joined: Sat Oct 16, 2004 1:25 pm
Sorry about that johnnyutah, I missed that part. How about this one then. It's for Win apps only.
Code: Select all
Procedure WinCallback(hWnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pNMHDR.NMHDR = lparam
; --> Is this our EditorGadget
If *pNMHDR\hwndFrom = GadgetID(0)
Select *pNMHDR\code
Case #EN_MSGFILTER
*pMSGFILTER.MSGFILTER = lparam
; --> If the key pressed is the Tab key
If *pMSGFILTER\wparam = #VK_TAB
; --> Activate next gadget
ActivateGadget(1)
; --> Return non-zero to ignore the Tab key
result = 1
EndIf
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0,0,0,322,170,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"EditorGadget") And CreateGadgetList(WindowID(0))
SetWindowCallback(@WinCallback())
EditorGadget (0,8,8,306,133,#PB_Container_Raised)
; --> Tell the EditorGadget we want ot filter keyboard messages
; --> We catch the events in the #WM_NOTIFY msg in our CallBack procedure
SendMessage_(GadgetID(0), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
ButtonGadget(1, 10, 140, 100, 20, "HI")
For a=0 To 5
AddGadgetItem(0,a,"Line "+Str(a))
Next
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
Put this one through the ringer and see if I got it right this time. 

Code: Select all
Procedure WinCallback(hWnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pNMHDR.NMHDR = lparam
; --> Is this our EditorGadget
Select *pNMHDR\hwndFrom
Case GadgetID(0)
Select *pNMHDR\code
Case #EN_MSGFILTER
*pMSGFILTER.MSGFILTER = lparam
; --> If the key pressed is the Tab key
If *pMSGFILTER\wparam = #VK_TAB And *pMSGFILTER\msg <> #WM_KEYUP
Debug *pMSGFILTER\msg
; --> Activate next gadget
ActivateGadget(1)
; --> Return non-zero to ignore the Tab key
result = 1
EndIf
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
Global currentGadget
If OpenWindow(0,0,0,322,170,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"EditorGadget") And CreateGadgetList(WindowID(0))
SetWindowCallback(@WinCallback())
EditorGadget (0,8,8,306,133,#PB_Container_Raised)
; --> Tell the EditorGadget we want ot filter keyboard messages
; --> We catch the events in the #WM_NOTIFY msg in our CallBack procedure
SendMessage_(GadgetID(0), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
ButtonGadget(1, 10, 140, 100, 20, "HI")
For a=0 To 5
AddGadgetItem(0,a,"Line "+Str(a))
Next
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
-
- Addict
- Posts: 991
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA