Seite 1 von 1

Tabulator im EditorGadget verhindern

Verfasst: 11.12.2015 16:46
von Cläusel
Hallo zusammen,

ich möchte gerne mittels der TAB-Taste zwischen mehreren EditorGadgets springen. Das funktioniert auch soweit,
jedoch kann nicht verhindern, das der TAB noch im Editor übernommen wird. Hat da jemand eine Rat für mich?

(AddKeyboardShortcut für TAB funktioniert auch nicht...)

Code: Alles auswählen

Enumeration FormWindow
  #Window_0
EndEnumeration

Enumeration FormGadget
  #Editor_0
  #Editor_1
  #Editor_2
EndEnumeration

Procedure OpenWindow_0(x = 0, y = 0, width = 383, height = 240)
  OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(#Editor_0, 2, 2, 378, 76)
  EditorGadget(#Editor_1, 2, 80, 378, 76)
  EditorGadget(#Editor_2, 2, 158, 378, 76)
EndProcedure

OpenWindow_0()

Repeat
     Select WaitWindowEvent() 
     Case #WM_KEYDOWN
          If GetAsyncKeyState_(#VK_TAB)
               Select GetActiveGadget()
               Case #Editor_0:SetActiveGadget(#Editor_1)
               Case #Editor_1:SetActiveGadget(#Editor_2)
               Case #Editor_2:SetActiveGadget(#Editor_0)
               EndSelect
          EndIf
     Case #PB_Event_CloseWindow 
          End
     EndSelect
ForEver
Gruß Claus

Re: Tabulator im EditorGadget verhindern

Verfasst: 11.12.2015 17:03
von ts-soft

Code: Alles auswählen

EnableExplicit

Enumeration FormWindow
  #Window_0
EndEnumeration

Enumeration FormGadget
  #Editor_0
  #Editor_1
  #Editor_2
EndEnumeration

Procedure OpenWindow_0(x = 0, y = 0, width = 383, height = 240)
  OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(#Editor_0, 2, 2, 378, 76)
  EditorGadget(#Editor_1, 2, 80, 378, 76)
  EditorGadget(#Editor_2, 2, 158, 378, 76)
EndProcedure

Procedure WinCallback(hwnd, msg, wParam, lParam)
  Protected result = #PB_ProcessPureBasicEvents
  Protected *pMSGFILTER.MSGFILTER
 
  Select msg
    Case #WM_NOTIFY
      *pMSGFILTER = lParam
      Select *pMSGFILTER\nmhdr\code
        Case #EN_MSGFILTER
          If *pMSGFILTER\wParam = #VK_TAB And *pMSGFILTER\msg <> #WM_KEYUP
            Select *pMSGFILTER\nmhdr\idFrom
              Case #Editor_0
                SetActiveGadget(#Editor_1)
                result = 1
              Case #Editor_1
                SetActiveGadget(#Editor_2)
                result = 1
              Case #Editor_2
                SetActiveGadget(#Editor_0)
                result = 1
            EndSelect
          EndIf
      EndSelect
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow_0()
SendMessage_(GadgetID(#Editor_0), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
SendMessage_(GadgetID(#Editor_1), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
SendMessage_(GadgetID(#Editor_2), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
SetWindowCallback(@WinCallback())

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      End
  EndSelect
ForEver

Re: Tabulator im EditorGadget verhindern

Verfasst: 06.08.2018 13:00
von marcelx
Hallo zusammen,

wie kann ich dazu Tabulator in die EditorGadget eingeben (Tastenkombination?)

Gruß
MarcelX

Re: Tabulator im EditorGadget verhindern

Verfasst: 06.08.2018 15:40
von Nino
marcelx hat geschrieben:wie kann ich dazu Tabulator in die EditorGadget eingeben (Tastenkombination?)
Ja, [Alt]+9

Re: Tabulator im EditorGadget verhindern

Verfasst: 06.08.2018 16:20
von marcelx
Super, danke Nino

Re: Tabulator im EditorGadget verhindern

Verfasst: 07.08.2018 16:24
von marcelx
Hallo,

ich haben Formularen mit viele Gadget und wollte die Gadget-ID als List verwenden (wegen case).
Leider funktioniert es fast.
Einmal wieder beim erste Gadget angelangt, wird ein Tabulator eingefügt.
Kann jemand helfen?
Danke und Gruß
MarcelX

Code: Alles auswählen

EnableExplicit

Enumeration FormWindow
  #Window_0
EndEnumeration

Enumeration FormGadget
  #Editor_0
  #Editor_1
  #Editor_2
EndEnumeration

Global maxId=2
Global Dim listId(maxId)
Global indexId=0

Procedure OpenWindow_0(x = 0, y = 0, width = 383, height = 240)
  OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(#Editor_0, 2, 2, 378, 76)
  StringGadget(#Editor_1, 2, 100, 378, 20, "")
  EditorGadget(#Editor_2, 2, 158, 378, 76)
EndProcedure

Procedure WinCallback(hwnd, msg, wParam, lParam)
  Protected result = #PB_ProcessPureBasicEvents
  Protected *pMSGFILTER.MSGFILTER
 
  Select msg
    Case #WM_NOTIFY
      *pMSGFILTER = lParam
      Select *pMSGFILTER\nmhdr\code
        Case #EN_MSGFILTER
          If *pMSGFILTER\wParam = #VK_TAB And *pMSGFILTER\msg <> #WM_KEYUP
            Select *pMSGFILTER\nmhdr\idFrom
              Case maxId ; end
                indexId=0
                SetActiveGadget(indexId)
                result = 1
              Case indexId To maxId-1
                indexId+1
                SetActiveGadget(indexId)
                result = 1
            EndSelect
          EndIf
      EndSelect
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow_0()

listId(0) = #Editor_0
listId(1) = #Editor_1
listId(2) = #Editor_2

Define i
For i=0 To maxId
  SendMessage_(GadgetID(listId(i)), #EM_SETEVENTMASK, 0, #ENM_KEYEVENTS)
Next

SetWindowCallback(@WinCallback())

SetActiveGadget(listId(indexId))
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      End
  EndSelect
ForEver

Re: Tabulator im EditorGadget verhindern

Verfasst: 07.08.2018 20:28
von mk-soft
Sorry, alles schon fertig... Hatte ich vergessen
Link: viewtopic.php?f=8&t=30853

Update - Mit 'ALT-GR + T' Tab einfügen

Code: Alles auswählen

;-TOP

; Comment : Module SetGadgetCallback (Windows Only)
; Author  : mk-soft
; Version : v0.02
; Created : 10.06.2018
; Updated : 
;
; Syntax Callback:
;           Procedure GadgetCB(hWnd,uMsg,wParam,lParam)
;             Select uMsg
;               ;TODO
;             EndSelect
;             ; Call previous gadget procedure
;             ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
;           EndProcedure
;
; *****************************************************************************

DeclareModule GadgetCallback
  
  Declare SetGadgetCallback(Gadget, *lpNewFunc) 
  Declare CallGadgetProc(hWnd, uMsg, wParam, lParam)
  
EndDeclareModule

Module GadgetCallback
  
  EnableExplicit
  
  Global NewMap *lpPrevFunc()
  Global MutexCB = CreateMutex()
  
  ; ---------------------------------------------------------------------------
  
  Procedure SetGadgetCallback(Gadget, *lpNewFunc)
    Protected GadgetID, GadgetKey.s
    
    GadgetID = GadgetID(Gadget)
    GadgetKey = Hex(GadgetID)
    
    ; Remove exists Callback
    If FindMapElement(*lpPrevFunc(), GadgetKey)
      SetWindowLongPtr_(GadgetID, #GWL_WNDPROC, *lpPrevFunc())
      DeleteMapElement(*lpPrevFunc())
    EndIf
    
    If *lpNewFunc
      If AddMapElement(*lpPrevFunc(), GadgetKey)
        *lpPrevFunc() = SetWindowLongPtr_(GadgetID, #GWL_WNDPROC, *lpNewFunc)
        ProcedureReturn *lpPrevFunc()
      EndIf
    EndIf
    
    ProcedureReturn 0
    
  EndProcedure
  
  ; ---------------------------------------------------------------------------
  
  Procedure CallGadgetProc(hWnd, uMsg, wParam, lParam)
    Protected result
    
    LockMutex(MutexCB)
    If FindMapElement(*lpPrevFunc(), Hex(hWnd))
      result = CallWindowProc_(*lpPrevFunc(), hWnd, uMsg, wParam, lParam)
    EndIf
    UnlockMutex(MutexCB)
    
    ProcedureReturn result
    
  EndProcedure
  
EndModule

; *****************************************************************************

; Example

CompilerIf #PB_Compiler_IsMainFile
  
  UseModule GadgetCallback
  
  Procedure RichEditProc(hWnd,uMsg,wParam,lParam)
    Select uMsg
      Case #WM_CHAR
        Debug Hex(lParam)
        If wParam = #VK_TAB
          Debug Hex(lParam)
          SetFocus_(GetWindow_(hWnd,#GW_HWNDNEXT))
          ProcedureReturn 1
        ElseIf lParam = $20140001 ; Alt-Gr 'T' -> Tab einfügen
          wParam = #VK_TAB
          lParam =$F0001
        EndIf
    EndSelect
    ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
  EndProcedure
  
  If OpenWindow(0,0,0,740,250,"Example SetGadgetCallback (Alt-Gr 'T' -> Tab einfügen)",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    EditorGadget(1,10,10,230,200)
    EditorGadget(2,250,10,230,200)
    EditorGadget(3,490,10,230,200)
    
    SetGadgetCallback(1, @RichEditProc())
    SetGadgetCallback(2, @RichEditProc())
    SetGadgetCallback(3, @RichEditProc())
    
    ; SetGadgetCallback(1, 0)
    ; SetGadgetCallback(2, 0)
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
  
CompilerEndIf
Shift-Tab geht automatisch.

Re: Tabulator im EditorGadget verhindern

Verfasst: 08.08.2018 10:33
von marcelx
Hallo mk-soft,

ich habe deine Code mit list-ID angepasst und so funktioniert; danke:

Code: Alles auswählen

DeclareModule GadgetCallback
 
  Declare SetGadgetCallback(Gadget, *lpNewFunc)
  Declare CallGadgetProc(hWnd, uMsg, wParam, lParam)
 
EndDeclareModule

Module GadgetCallback
 
  EnableExplicit
 
  Global NewMap *lpPrevFunc()
  Global MutexCB = CreateMutex()
 
  ; ---------------------------------------------------------------------------
 
  Procedure SetGadgetCallback(Gadget, *lpNewFunc)
    Protected GadgetID, GadgetKey.s
   
    GadgetID = GadgetID(Gadget)
    GadgetKey = Hex(GadgetID)
   
    ; Remove exists Callback
    If FindMapElement(*lpPrevFunc(), GadgetKey)
      SetWindowLongPtr_(GadgetID, #GWL_WNDPROC, *lpPrevFunc())
      DeleteMapElement(*lpPrevFunc())
    EndIf
   
    If *lpNewFunc
      If AddMapElement(*lpPrevFunc(), GadgetKey)
        *lpPrevFunc() = SetWindowLongPtr_(GadgetID, #GWL_WNDPROC, *lpNewFunc)
        ProcedureReturn *lpPrevFunc()
      EndIf
    EndIf
   
    ProcedureReturn 0
   
  EndProcedure
 
  ; ---------------------------------------------------------------------------
 
  Procedure CallGadgetProc(hWnd, uMsg, wParam, lParam)
    Protected result
   
    LockMutex(MutexCB)
    If FindMapElement(*lpPrevFunc(), Hex(hWnd))
      result = CallWindowProc_(*lpPrevFunc(), hWnd, uMsg, wParam, lParam)
    EndIf
    UnlockMutex(MutexCB)
   
    ProcedureReturn result
   
  EndProcedure
 
EndModule

; *****************************************************************************

; Example

CompilerIf #PB_Compiler_IsMainFile
 
  UseModule GadgetCallback
 
  Procedure RichEditProc(hWnd,uMsg,wParam,lParam)
    Select uMsg
      Case #WM_CHAR
        If wParam = #VK_TAB
          SetFocus_(GetWindow_(hWnd,#GW_HWNDNEXT))
          ProcedureReturn 1
        EndIf
    EndSelect
    ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
  EndProcedure
  
  Global maxId=2
  Global Dim listId(maxId)
    
  If OpenWindow(0,0,0,740,250,"Example SetGadgetCallback",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    listId(0) = 1
    listId(1) = 2
    listId(2) = 3    
    EditorGadget(listId(0),10,10,230,200)
    StringGadget(listId(1),250,10,230,20, "")
    EditorGadget(listId(2),490,10,230,200)
 

    Define i
    For i=0 To maxId
      SetGadgetCallback(listId(i), @RichEditProc())
    Next

    SetActiveGadget(listId(0))
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
 
CompilerEndIf
Gruß MarcelX