Page 1 of 1

Tabbing through EditorGadgets How?

Posted: Mon Nov 09, 2015 8:56 pm
by mqsymth
How do you tab through EditorGadgets. I want to be able to hit the tab key and have the cursor move to the next editor gadget in the series. When I hit the tab Key it stays in the same editor gadget. Below is my code.

Thanks for any help with this.

Code: Select all

EnableExplicit

Enumeration FormGadget
  #WinMain
  #Text_0
  #Text_1
  #Text_3
  #Text_4
  #Text_6
  #text_7
  #txtInDir
  #txtOutDir
  #txtStub
  #txtUID
  #txtiStart
  #txtiEnd
  #CB_EXIT
  #CB_Stop
EndEnumeration


Enumeration FormFont
  #Font_WinMain_0
EndEnumeration


LoadFont(#Font_WinMain_0,"Arial", 9, #PB_Font_Bold)

;========================================================================================
Procedure Win()
  Protected iFlags.i = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered
  If OpenWindow(#WinMain, 0, 0,500, 200, "WhyNoTabs", iFlags)
    SetWindowColor(#WinMain, RGB(255,255,128))

  TextGadget(#Text_0, 10, 10, 48, 30, "Input Dir")
  SetGadgetColor(#Text_0, #PB_Gadget_FrontColor,RGB(0,0,0))
  SetGadgetColor(#Text_0, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_0, FontID(#Font_WinMain_0))
  TextGadget(#Text_1, 10, 50, 60, 30, "Output Directory")
  SetGadgetColor(#Text_1, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_1, FontID(#Font_WinMain_0))
  TextGadget(#Text_3, 10, 90, 70, 25, "Stub")
  SetGadgetColor(#Text_3, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_3, FontID(#Font_WinMain_0))
  TextGadget(#Text_4, 200, 90, 50, 25, "Run ID")
  SetGadgetColor(#Text_4, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_4, FontID(#Font_WinMain_0))
  TextGadget(#Text_6, 10, 130, 50, 30, "Start File Date")
  SetGadgetColor(#Text_6, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_6, FontID(#Font_WinMain_0))
  TextGadget(#text_7, 200, 130, 50, 30, "End File Date")
  SetGadgetColor(#text_7, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#text_7, FontID(#Font_WinMain_0))
  
  EditorGadget(#txtInDir, 80, 10, 370, 20)
  EditorGadget(#txtOutDir, 80, 50, 370, 20)
  EditorGadget(#txtStub, 80, 90, 90, 20)
  EditorGadget(#txtUID, 260, 90, 90, 20)
  EditorGadget(#txtiStart, 80, 130, 90, 20)
  EditorGadget(#txtiEnd, 260, 130, 90, 20)
  
  ButtonGadget(#CB_EXIT, 130, 160, 65, 30, "Exit")
  SetGadgetFont(#CB_EXIT, FontID(#Font_WinMain_0))
  ButtonGadget(#CB_Stop, 310, 160, 65, 30, "Stop")
  SetGadgetFont(#CB_Stop, FontID(#Font_WinMain_0))

  
    EndIf
EndProcedure
;=========================================================================
Procedure WaitForUser()
  Protected iExit = #False
  Protected sInpFilesDir.s = "", sOutFilesDir.s=""
  Protected l.l,sStub.s,sTemp.s,sFileName.s,lR.l
  Define Event

  Repeat
    Event=WaitWindowEvent()
    
      Select Event
        Case #PB_Event_CloseWindow:
          iExit = #True
          Break
        Case #PB_Event_Gadget
          Select EventGadget()
             Case #CB_EXIT
               iExit = #True
               Break
             Case #CB_STOP
           EndSelect
         EndSelect  
       Until iExit = #True
       End
EndProcedure

Win()
WaitForUser()

End


Re: Tabbing through EditorGadgets How?

Posted: Mon Nov 09, 2015 9:15 pm
by RSBasic
StringGadget() with #ES_MULTILINE or: http://www.rsbasic.de/aktualisierung/wi ... chalten.pb

Re: Tabbing through EditorGadgets How?

Posted: Mon Nov 09, 2015 9:36 pm
by mk-soft
Yes, but only Windows

Perhaps with "AddKeyboardShortcut(...)

Update
Now in both directions

Code: Select all

EnableExplicit

Enumeration Formwindow
  #WinMain
EndEnumeration

Enumeration FormGadget
  #Text_0
  #Text_1
  #Text_3
  #Text_4
  #Text_6
  #text_7
  #txtInDir
  #txtOutDir
  #txtStub
  #txtUID
  #txtiStart
  #txtiEnd
  #CB_EXIT
  #CB_Stop
EndEnumeration


Enumeration FormFont
  #Font_WinMain_0
EndEnumeration

Enumeration 
  #Menu_Tab
  #Menu_Shift_Tab
EndEnumeration

LoadFont(#Font_WinMain_0,"Arial", 9, #PB_Font_Bold)

Procedure TabToNextGadget(FirstGadget, LastGadget, Reverse = #False)
  
  Protected start, pos
  
  start = GetActiveGadget()
  pos = start
  Repeat
    If Reverse
      pos - 1
      If pos < FirstGadget
        pos = LastGadget
      EndIf
    Else
      pos + 1
      If pos > LastGadget
        pos = FirstGadget
      EndIf
    EndIf
    If GadgetType(pos) = #PB_GadgetType_Editor Or GadgetType(pos) = #PB_GadgetType_String
      SetActiveGadget(pos)
      Break
    EndIf
    If pos = start
      Break
    EndIf
  ForEver
  
EndProcedure


;========================================================================================
Procedure Win()
  Protected iFlags.i = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered
  If OpenWindow(#WinMain, 0, 0,500, 200, "WhyNoTabs", iFlags)
    SetWindowColor(#WinMain, RGB(255,255,128))

  TextGadget(#Text_0, 10, 10, 48, 30, "Input Dir")
  SetGadgetColor(#Text_0, #PB_Gadget_FrontColor,RGB(0,0,0))
  SetGadgetColor(#Text_0, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_0, FontID(#Font_WinMain_0))
  TextGadget(#Text_1, 10, 50, 60, 30, "Output Directory")
  SetGadgetColor(#Text_1, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_1, FontID(#Font_WinMain_0))
  TextGadget(#Text_3, 10, 90, 70, 25, "Stub")
  SetGadgetColor(#Text_3, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_3, FontID(#Font_WinMain_0))
  TextGadget(#Text_4, 200, 90, 50, 25, "Run ID")
  SetGadgetColor(#Text_4, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_4, FontID(#Font_WinMain_0))
  TextGadget(#Text_6, 10, 130, 50, 30, "Start File Date")
  SetGadgetColor(#Text_6, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_6, FontID(#Font_WinMain_0))
  TextGadget(#text_7, 200, 130, 50, 30, "End File Date")
  SetGadgetColor(#text_7, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#text_7, FontID(#Font_WinMain_0))
  
  EditorGadget(#txtInDir, 80, 10, 370, 20)
  EditorGadget(#txtOutDir, 80, 50, 370, 20)
  EditorGadget(#txtStub, 80, 90, 90, 20)
  EditorGadget(#txtUID, 260, 90, 90, 20)
  EditorGadget(#txtiStart, 80, 130, 90, 20)
  EditorGadget(#txtiEnd, 260, 130, 90, 20)
  
  ButtonGadget(#CB_EXIT, 130, 160, 65, 30, "Exit")
  SetGadgetFont(#CB_EXIT, FontID(#Font_WinMain_0))
  ButtonGadget(#CB_Stop, 310, 160, 65, 30, "Stop")
  SetGadgetFont(#CB_Stop, FontID(#Font_WinMain_0))

  AddKeyboardShortcut(#WinMain, #PB_Shortcut_Tab, #Menu_Tab)
  AddKeyboardShortcut(#WinMain, #PB_Shortcut_Tab | #PB_Shortcut_Shift, #Menu_Shift_Tab)
  
    EndIf
EndProcedure
;=========================================================================
Procedure WaitForUser()
  Protected iExit = #False
  Protected sInpFilesDir.s = "", sOutFilesDir.s=""
  Protected l.l,sStub.s,sTemp.s,sFileName.s,lR.l
  Define Event

  Repeat
    Event=WaitWindowEvent()
    
      Select Event
        Case #PB_Event_CloseWindow:
          iExit = #True
          Break
        Case #PB_Event_Gadget
          Select EventGadget()
             Case #CB_EXIT
               iExit = #True
               Break
             Case #CB_STOP
           EndSelect
           
         Case #PB_Event_Menu
           Select EventMenu()
             Case #Menu_Tab
               TabToNextGadget(#Text_0, #CB_EXIT)
             Case #Menu_Shift_Tab
               TabToNextGadget(#Text_0, #CB_EXIT, #True)
           EndSelect
           
        EndSelect
       
       Until iExit = #True
       End
EndProcedure

Win()
WaitForUser()

End

Re: Tabbing through EditorGadgets How?

Posted: Mon Nov 09, 2015 10:56 pm
by mqsymth
Many thanks MK-Soft and TSBasic.

In searching I found this simple code and it tabs buttongadgets and editorgadget but I don't know why this works because the above solutions require a lot more code.

Code: Select all

If OpenWindow(0, 0, 0, 220, 180, "TabDaGadgets...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(1, 10, 10, 200, 22, "click")
  EditorGadget(2, 10, 40, 200, 100)
  ButtonGadget(3, 10, 150, 200, 22, "click")
 
  Repeat
    wwe = WaitWindowEvent()
    Select wwe
      Case #PB_Event_CloseWindow 
        Quit = 1
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1 : Debug "Button 1"

          Case 2
            If FindString(GetGadgetText(2), Chr(9) ,0) > 0
              SetGadgetColor(2, #PB_Gadget_BackColor, RGB(Random(215)+100,Random(225)+100,Random(255)+100))
              SetGadgetText(2, RemoveString(GetGadgetText(2), Chr(9) ,0))
            SetActiveGadget(3)
          EndIf

          Case 3 : Debug "Button 3"
       EndSelect
    EndSelect
  Until wwe = #PB_Event_CloseWindow Or Quit = 1
EndIf

Re: Tabbing through EditorGadgets How?

Posted: Mon Nov 09, 2015 11:40 pm
by mk-soft
The code it´s only for one Gadget.

Re: Tabbing through EditorGadgets How?

Posted: Mon Nov 09, 2015 11:51 pm
by mqsymth
The following code works with the routine TabIt and gives more control of where the next Tab should go to.

Code: Select all

EnableExplicit

Enumeration FormGadget
  #WinMain
  #Text_0
  #Text_1
  #Text_3
  #Text_4
  #Text_6
  #text_7
  #txtInDir
  #txtOutDir
  #txtStub
  #txtUID
  #txtiStart
  #txtiEnd
  #CB_EXIT
  #CB_Stop
EndEnumeration


Enumeration FormFont
  #Font_WinMain_0
EndEnumeration


LoadFont(#Font_WinMain_0,"Arial", 9, #PB_Font_Bold)

Procedure TabIt(lThis.l,lNext)
  If FindString(GetGadgetText(lThis),Chr(9),0)>0
    SetGadgetText(lThis,RemoveString(GetGadgetText(lthis),Chr(9),0))
    SetActiveGadget(lNext)
  EndIf
EndProcedure 
    

;========================================================================================
Procedure Win()
  Protected iFlags.i = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered
  If OpenWindow(#WinMain, 0, 0,500, 200, "WhyNoTabs", iFlags)
    SetWindowColor(#WinMain, RGB(255,255,128))

  TextGadget(#Text_0, 10, 10, 48, 30, "Input Dir")
  SetGadgetColor(#Text_0, #PB_Gadget_FrontColor,RGB(0,0,0))
  SetGadgetColor(#Text_0, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_0, FontID(#Font_WinMain_0))
  TextGadget(#Text_1, 10, 50, 60, 30, "Output Directory")
  SetGadgetColor(#Text_1, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_1, FontID(#Font_WinMain_0))
  TextGadget(#Text_3, 10, 90, 70, 25, "Stub")
  SetGadgetColor(#Text_3, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_3, FontID(#Font_WinMain_0))
  TextGadget(#Text_4, 200, 90, 50, 25, "Run ID")
  SetGadgetColor(#Text_4, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_4, FontID(#Font_WinMain_0))
  TextGadget(#Text_6, 10, 130, 50, 30, "Start File Date")
  SetGadgetColor(#Text_6, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#Text_6, FontID(#Font_WinMain_0))
  TextGadget(#text_7, 200, 130, 50, 30, "End File Date")
  SetGadgetColor(#text_7, #PB_Gadget_BackColor,RGB(255,255,128))
  SetGadgetFont(#text_7, FontID(#Font_WinMain_0))
  
  EditorGadget(#txtInDir, 80, 10, 370, 20)
  EditorGadget(#txtOutDir, 80, 50, 370, 20)
  EditorGadget(#txtStub, 80, 90, 90, 20)
  EditorGadget(#txtUID, 260, 90, 90, 20)
  EditorGadget(#txtiStart, 80, 130, 90, 20)
  EditorGadget(#txtiEnd, 260, 130, 90, 20)
  
  ButtonGadget(#CB_EXIT, 130, 160, 65, 30, "Exit")
  SetGadgetFont(#CB_EXIT, FontID(#Font_WinMain_0))
  ButtonGadget(#CB_Stop, 310, 160, 65, 30, "Stop")
  SetGadgetFont(#CB_Stop, FontID(#Font_WinMain_0))

  
    EndIf
EndProcedure
;=========================================================================
Procedure WaitForUser()
  Protected iExit = #False
  Protected sInpFilesDir.s = "", sOutFilesDir.s=""
  Protected l.l,sStub.s,sTemp.s,sFileName.s,lR.l
  Define Event

  Repeat
    Event=WaitWindowEvent()
    
      Select Event
        Case #PB_Event_CloseWindow:
          iExit = #True
          Break
        Case #PB_Event_Gadget
          Select EventGadget()
            ;Case #txtIndir : If FindString(GetGadgetText(#txtIndir),Chr(9),0)>0: SetActiveGadget(#txtOutDir) :EndIf
            Case #txtIndir : TabIt(#txtInDir,#txtOutDir) 
            Case #txtOutdir: Tabit(#txtoutdir,#txtstub)
            Case #txtstub : Tabit(#txtStub,#txtUID)
            Case #txtUID : Tabit(#txtUID,#txtiStart)
            Case #txtiStart : Tabit(#txtiStart,#txtiEnd)
            Case #txtiEnd  : Tabit(#txtiEnd,#txtInDir)
             Case #CB_EXIT
               iExit = #True
               Break
             Case #CB_STOP
           EndSelect
         EndSelect  
       Until iExit = #True
       End
EndProcedure

Win()
WaitForUser()

End

Re: Tabbing through EditorGadgets How?

Posted: Tue Nov 10, 2015 1:06 am
by ts-soft
Only for Windows!

Code: Select all

EnableExplicit

; changed
Procedure Callback(hWnd, uMsg, wParam, lParam)
  Protected oldproc = GetProp_(hWnd, "oldproc")
  
  Select uMsg
    Case #WM_NCDESTROY
      RemoveProp_(hWnd, "oldproc")
      
    Case #WM_CHAR
      If wParam = #VK_TAB
        ProcedureReturn 0
      EndIf
      
    Case #WM_KEYDOWN
      If wParam = #VK_TAB
        SetFocus_(GetNextDlgTabItem_(GetParent_(hWnd), hWnd, #False))
        ProcedureReturn 0
      EndIf
      
  EndSelect
  
  ProcedureReturn CallWindowProc_(oldproc, hWnd, uMsg, wParam, lParam)
EndProcedure

Procedure SetCustomCallback(ID)
  Protected oldproc = SetWindowLongPtr_(GadgetID(ID), #GWL_WNDPROC, @Callback())
  ProcedureReturn SetProp_(GadgetID(ID), "oldproc", oldproc)
EndProcedure
; changed end

Enumeration FormGadget
  #WinMain
  #Text_0
  #Text_1
  #Text_3
  #Text_4
  #Text_6
  #text_7
  #txtInDir
  #txtOutDir
  #txtStub
  #txtUID
  #txtiStart
  #txtiEnd
  #CB_EXIT
  #CB_Stop
EndEnumeration


Enumeration FormFont
  #Font_WinMain_0
EndEnumeration


LoadFont(#Font_WinMain_0,"Arial", 9, #PB_Font_Bold)

;========================================================================================
Procedure Win()
  Protected iFlags.i = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered
  If OpenWindow(#WinMain, 0, 0,500, 200, "WhyNoTabs", iFlags)
    SetWindowColor(#WinMain, RGB(255,255,128))
    
    TextGadget(#Text_0, 10, 10, 48, 30, "Input Dir")
    SetGadgetColor(#Text_0, #PB_Gadget_FrontColor,RGB(0,0,0))
    SetGadgetColor(#Text_0, #PB_Gadget_BackColor,RGB(255,255,128))
    SetGadgetFont(#Text_0, FontID(#Font_WinMain_0))
    TextGadget(#Text_1, 10, 50, 60, 30, "Output Directory")
    SetGadgetColor(#Text_1, #PB_Gadget_BackColor,RGB(255,255,128))
    SetGadgetFont(#Text_1, FontID(#Font_WinMain_0))
    TextGadget(#Text_3, 10, 90, 70, 25, "Stub")
    SetGadgetColor(#Text_3, #PB_Gadget_BackColor,RGB(255,255,128))
    SetGadgetFont(#Text_3, FontID(#Font_WinMain_0))
    TextGadget(#Text_4, 200, 90, 50, 25, "Run ID")
    SetGadgetColor(#Text_4, #PB_Gadget_BackColor,RGB(255,255,128))
    SetGadgetFont(#Text_4, FontID(#Font_WinMain_0))
    TextGadget(#Text_6, 10, 130, 50, 30, "Start File Date")
    SetGadgetColor(#Text_6, #PB_Gadget_BackColor,RGB(255,255,128))
    SetGadgetFont(#Text_6, FontID(#Font_WinMain_0))
    TextGadget(#text_7, 200, 130, 50, 30, "End File Date")
    SetGadgetColor(#text_7, #PB_Gadget_BackColor,RGB(255,255,128))
    SetGadgetFont(#text_7, FontID(#Font_WinMain_0))
    
    EditorGadget(#txtInDir, 80, 10, 370, 20)
    EditorGadget(#txtOutDir, 80, 50, 370, 20)
    EditorGadget(#txtStub, 80, 90, 90, 20)
    EditorGadget(#txtUID, 260, 90, 90, 20)
    EditorGadget(#txtiStart, 80, 130, 90, 20)
    EditorGadget(#txtiEnd, 260, 130, 90, 20)
    
    ButtonGadget(#CB_EXIT, 130, 160, 65, 30, "Exit")
    SetGadgetFont(#CB_EXIT, FontID(#Font_WinMain_0))
    ButtonGadget(#CB_Stop, 310, 160, 65, 30, "Stop")
    SetGadgetFont(#CB_Stop, FontID(#Font_WinMain_0))
    
    ; changed
    SetCustomCallback(#txtInDir)
    SetCustomCallback(#txtOutDir)
    SetCustomCallback(#txtStub)
    SetCustomCallback(#txtUID)
    SetCustomCallback(#txtiStart)
    SetCustomCallback(#txtiEnd)
    
    SetActiveGadget(#txtInDir)
    SendMessage_(WindowID(#WinMain), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)
    ; changed end
    
  EndIf
EndProcedure
;=========================================================================
Procedure WaitForUser()
  Protected iExit = #False
  Protected sInpFilesDir.s = "", sOutFilesDir.s=""
  Protected l.l,sStub.s,sTemp.s,sFileName.s,lR.l
  Define Event
  
  Repeat
    Event=WaitWindowEvent()
    
    Select Event
      Case #PB_Event_CloseWindow:
        iExit = #True
        Break
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #CB_EXIT
            iExit = #True
            Break
          Case #CB_STOP
        EndSelect
    EndSelect
  Until iExit = #True
  End
EndProcedure

Win()
WaitForUser()

End

Re: Tabbing through EditorGadgets How?

Posted: Tue Nov 10, 2015 11:10 am
by RASHAD

Code: Select all

If OpenWindow(0, 0, 0, 220, 180, "Tab EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(1, 10, 10, 200, 22)
  ButtonGadget(2, 10, 40, 80, 22,"Click #1")
  EditorGadget(3, 10, 70, 200, 22)
  EditorGadget(4, 10, 100, 200, 22)
  ButtonGadget(5, 10, 150, 80, 22, "Clicl #2")
  SendMessage_(WindowID(0), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)
  SetActiveGadget(1)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow 
        Quit = 1
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1,3,4
            If Right(GetGadgetText(EventGadget()),1) = Chr(9)
              SetGadgetText(EventGadget(),Trim(GetGadgetText(EventGadget()), Chr(9)))
              SetActiveGadget(EventGadget()+1)
              SendMessage_(GadgetID(EventGadget()), #EM_SETSEL, -1 ,-1)
            EndIf
       EndSelect
    EndSelect
  Until Quit = 1
EndIf


Re: Tabbing through EditorGadgets How?

Posted: Tue Nov 10, 2015 4:27 pm
by mk-soft
My code "TabToNextGadget" don´t work on Windows :?:

Small upate from Rashad nice code

Code: Select all

If OpenWindow(0, 0, 0, 220, 180, "Tab EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(1, 10, 10, 200, 22)
  ButtonGadget(2, 10, 40, 80, 22,"Click #1")
  EditorGadget(3, 10, 70, 200, 22)
  StringGadget(4, 10, 100, 200, 22, "")
  ButtonGadget(5, 10, 150, 80, 22, "Clicl #2")
  SendMessage_(WindowID(0), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)
  SetActiveGadget(1)
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
       
      Case #PB_Event_Gadget
        If GadgetType(EventGadget()) = #PB_GadgetType_Editor;
          If Right(GetGadgetText(EventGadget()),1) = Chr(9)
            SetGadgetText(EventGadget(),Trim(GetGadgetText(EventGadget()), Chr(9)))
            SetActiveGadget(EventGadget()+1)
            SendMessage_(GadgetID(EventGadget()), #EM_SETSEL, -1 ,-1)
          EndIf
        EndIf
    EndSelect
  Until Quit = 1
EndIf

Re: Tabbing through EditorGadgets How?

Posted: Tue Nov 10, 2015 7:35 pm
by mqsymth
Many thanks to ts-soft, RASHAD and mk-soft for your help. Much appreciated.

Buttons are automatically Tabbed to. In RASHAD's code and the modified by mk-soft version, tabbing not only tabs to the EditorGadget but also to the ButtonGadget. The Buttons are not skipped.

Re: Tabbing through EditorGadgets How?

Posted: Wed Nov 11, 2015 3:17 am
by RASHAD
Only tabbing the EditorGadgets

Code: Select all

If OpenWindow(0, 0, 0, 220, 180, "Tab & EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(1, 10, 10, 200, 22)
  ButtonGadget(2, 10, 40, 80, 22,"Click #1")
  EditorGadget(3, 10, 70, 200, 22)
  EditorGadget(4, 10, 100, 200, 22)
  ButtonGadget(5, 10, 150, 80, 22, "Clicl #2")
  ;SendMessage_(WindowID(0), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)
  SetActiveGadget(1)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow 
        Quit = 1
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1,3,4
            If Right(GetGadgetText(EventGadget()),1) = Chr(9)
              SetGadgetText(EventGadget(),Trim(GetGadgetText(EventGadget()),Chr(9)))
              If EventGadget() >= 4
                 SetActiveGadget(1)
              Else
                For x = 1 To 5
                  If GadgetType(EventGadget()+x) = #PB_GadgetType_Editor
                     SetActiveGadget(EventGadget()+x)
                     Break
                  EndIf
                Next
              EndIf
              SendMessage_(GadgetID(EventGadget()), #EM_SETSEL, -1 ,-1)
            EndIf
       EndSelect
    EndSelect
  Until Quit = 1
EndIf

Re: Tabbing through EditorGadgets How?

Posted: Sat Nov 14, 2015 6:12 pm
by mqsymth
When you tab to a new EditorGadget and select the text with SendMessage_ how do you tab to the next EditorGadget without the text that was selected in the previous editor box being deleted? If I put the cursor at the of the text, the text is not longer selected.
In addition, when the EditorGadget is selected you can't see the cursor. should the cursor color be changed?

What I wish to do is hit the tab key, highlight and select the text in the next editorgadget and if I don't want to change that text hit the tab key again. The text would remain and the next editorgadget text would be selected, etc with the tab key.

Thanks for any help with this.

Code: Select all

;=============================================================================
Procedure TabIt(lThis.l,lNext.l)
  If FindString(GetGadgetText(lThis),Chr(9),0)>0
    SetGadgetText(lThis,RemoveString(GetGadgetText(lthis),Chr(9),0))
    SetActiveGadget(lNext)
    iTextLen=Len(GetGadgetText(lNext))
    SendMessage_(GadgetID(lNext), #EM_SETSEL, 0 ,-1)
    ;SendMessage_(GadgetID(lNext), #EM_SETSEL, -1 ,-1)   
    ;SendMessage_(GadgetID(lNext), #EM_SETSEL, iTextLen ,iTextLen)   
  EndIf
EndProcedure 
;===============================================================
Procedure Win()
If OpenWindow(0, 0, 0, 220, 180, "Tab & EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(1, 10, 10, 200, 22)
  ButtonGadget(2, 10, 40, 80, 22,"Click #1")
  EditorGadget(3, 10, 70, 200, 22)
  EditorGadget(4, 10, 100, 200, 22)
  ButtonGadget(5, 10, 150, 80, 22, "Click #2")
  ;SendMessage_(WindowID(0), #WM_CHANGEUISTATE, 2 | (1 << 16), 0)

  SetGadgetText(1,"aaaa")
  SetGadgetText(3,"bbbb")
  SetGadgetText(4,"cccc")
  SetActiveGadget(1)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1 : TabIt(1,3)
          Case 3 : TabIt(3,4)
          Case 4 : TabIt(4,1)  
      EndSelect
    EndSelect
  Until Quit = 1
EndIf
EndProcedure
win()
End

Re: Tabbing through EditorGadgets How?

Posted: Sat Nov 14, 2015 10:48 pm
by mqsymth
Here is an easy solution to selection, highlighting and tabbing that works with StringGadget. This includes skipping tabs on buttons.
Credit jassing for RemoveTabStop and AddTabStop procedures.
Credit byo with #PB_EventType_Focus routine.

Code: Select all

;======================================================
Procedure AddTabStop(nGadget)
   Protected nStyle, hWnd
   hWnd = GadgetID(nGadget)
   nStyle=GetWindowLong_(hWnd, #GWL_STYLE)
   SetWindowLong_(hWnd, #GWL_STYLE, nStyle|#WS_TABSTOP )
 EndProcedure
 ;=====================================================
Procedure RemoveTabStop(nGadget)
   Protected nStyle, hWnd
   hWnd = GadgetID(nGadget)
   nStyle=GetWindowLong_(hWnd, #GWL_STYLE)
   SetWindowLong_(hWnd, #GWL_STYLE, nStyle!#WS_TABSTOP )
EndProcedure  
;=============================================================================

If OpenWindow(0, 0, 0, 220, 180, "Tab & EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
  
  StringGadget(1, 10, 10, 200, 22,"",#ES_MULTILINE)
  StringGadget(3, 10, 70, 200, 22,"",#ES_MULTILINE)
  StringGadget(4, 10, 100, 200, 22,"",#ES_MULTILINE)
  
  ButtonGadget(5, 10, 150, 80, 22, "Click #2")
  ButtonGadget(2, 10, 40, 80, 22,"Click #1") 

  SetGadgetText(1,"aaaa")
  SetGadgetText(3,"bbbb")
  SetGadgetText(4,"cccc")
  SetActiveGadget(1)
  
  RemoveTabStop(5)
  RemoveTabStop(2)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
       
      Case #PB_Event_Gadget
        Select EventType()
          Case #PB_EventType_Focus
            If GadgetType(EventGadget()) = #PB_GadgetType_String
              SendMessage_(GadgetID(EventGadget()), #EM_SETSEL, 0, -1)
            EndIf
        EndSelect ;EventType
    EndSelect ;WaitWindowEvent
  Until Quit = 1
EndIf

End