Page 1 of 1

Tab to next panel

Posted: Mon Jun 27, 2005 7:18 pm
by johnnyutah
Hi,

I need to automatically select the next panel when someone presses tab in the last string gadget of the previous panel. Is this possible?

Posted: Mon Jun 27, 2005 7:47 pm
by Num3
Yes it is....

Code: Select all

;-Window Constants
Enumeration 1
  #Window_Form1
EndEnumeration
#WindowIndex=#PB_Compiler_EnumerationValue


;-Gadget Constants
Enumeration 1
  ;Window_Form1
  #Gadget_Form1_Panel2
  #Gadget_Form1_Panel2Tab3
  #Gadget_Form1_Panel2Tab4
  #Gadget_Form1_String1
  #Gadget_Form1_String2
  #Gadget_Form1_String3
EndEnumeration
#GadgetIndex=#PB_Compiler_EnumerationValue

Procedure.l Window_Form1()
  If OpenWindow(#Window_Form1,169,179,220,179,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible,"Work Form1")
    If CreateGadgetList(WindowID(#Window_Form1))
      PanelGadget(#Gadget_Form1_Panel2,10,10,200,150)
      AddGadgetItem(#Gadget_Form1_Panel2,-1,"Tab3")
      StringGadget(#Gadget_Form1_String1,15,10,80,20,"")
      StringGadget(#Gadget_Form1_String2,15,40,80,20,"")
      AddGadgetItem(#Gadget_Form1_Panel2,-1,"Tab4")
      StringGadget(#Gadget_Form1_String3,15,10,80,20,"")
      CloseGadgetList()
      HideWindow(#Window_Form1,0)
      ProcedureReturn WindowID()
    EndIf
  EndIf
EndProcedure

;-Main Loop
If Window_Form1()
  
  quitForm1=0
  Repeat
    EventID=WaitWindowEvent()
    Select EventID
      
      Case #PB_Event_CloseWindow
        If EventWindowID()=#Window_Form1
          quitForm1=1
        EndIf
        
      Case #PB_Event_Gadget
        Select EventGadgetID()
          Case #Gadget_Form1_String1
            
          Case #Gadget_Form1_String2
            If EventType()=#PB_EventType_LostFocus ; String gadget lost focus
              SetGadgetState(#Gadget_Form1_Panel2,1)
            EndIf
            
        EndSelect
        
    EndSelect
  Until quitForm1
  CloseWindow(#Window_Form1)
EndIf
End

Posted: Mon Jun 27, 2005 10:27 pm
by johnnyutah
I also had to do this for a combo box gadget and your excellent code put me on the right track. If you need to change to the next panel if a combo box gadget loses focus just substitute

If EventType()=#PB_EventType_LostFocus

with

If GetFocus_() <> GetWindow_(GadgetID(#Name of gadget), #GW_CHILD)

Thanks a lot Num3.

Posted: Mon Jun 27, 2005 10:47 pm
by johnnyutah
Sorry to be a pain but I also need to do this for a check box gadget but both methods mentioned in my last post don't work to detect that the focus has been lost. Can anyone shed some light on this?