Travel thru Gadgets

Share your advanced PureBasic knowledge/code with the community.
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Travel thru Gadgets

Post by VB6_to_PBx »

Travel thru Gadgets ( example 1)

Code: Select all

EnableExplicit

;- Global
Global.i Window_0
Global.i Combo_1
Global.i Combo_2
Global.i Combo_3
Global.i Combo_4
Global.i WW, EW, EM, EG, ET, AG   ;<<--- WW= WaitWindowEvent()  EW= EventWindow()  EM= EventMenu()  EG= EventGadget()  ET= EventType()  AG= GetActiveGadget()

;========================================================
;-[ Keyboard Shortcut Constants ]
;========================================================
#KeyReturn=10013 : #KeyEscape=10027 : #KeyPageUp=10033 : #KeyPageDown=10034 : #KeyEnd=10035 : #KeyHome=10036 : #KeyUp=10038 : #KeyDown=10040


;- Declare
Declare Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)

Procedure Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)
  Window_0 = OpenWindow(#PB_Any, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

  ;=====================================================================
  ;- Add Keyboard Shortcuts to travel thru Inputs
  ;=====================================================================
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Return,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Escape,#KeyEscape)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageDown,#KeyPageDown)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageUp,#KeyPageUp)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab | #PB_Shortcut_Shift,#KeyEscape)

  Combo_1 = ComboBoxGadget(#PB_Any, 128, 89, 144, 29)
            AddGadgetItem(Combo_1, -1, "Combo_1")
            SetGadgetState(Combo_1, 0)
            SetGadgetData(Combo_1,1)

  Combo_4 = ComboBoxGadget(#PB_Any, 133, 247, 137, 31)
            AddGadgetItem(Combo_4, -1, "Combo_4")
            SetGadgetState(Combo_4, 0)
            SetGadgetData(Combo_4,4)

  Combo_2 = ComboBoxGadget(#PB_Any, 129, 147, 141, 27)
            AddGadgetItem(Combo_2, -1, "Combo_2")
            SetGadgetState(Combo_2, 0)
            SetGadgetData(Combo_2,2)

  Combo_3 = ComboBoxGadget(#PB_Any, 128, 198, 145, 27)
            AddGadgetItem(Combo_3, -1, "Combo_3")
            SetGadgetState(Combo_3, 0)
            SetGadgetData(Combo_3,3)

  SetActiveGadget(Combo_1)

EndProcedure

;- Main Program
Open_Window_0()

;- Event Loop
Repeat
  WW = WaitWindowEvent(10) ;<<--- Wait until a new Window or Gadget Event occurs.  ( 10 = the timeout in milliseconds or 1000 milliseconds = 1 second ) 
  EW = EventWindow()       ;<<--- In Programs with more than one Form or Window, which Window did the Event occur on
  EM = EventMenu()         ;<<--- Which Menu did the Event occur on
  EG = EventGadget()       ;<<--- Which Gadget did the Event occur on ( #PB_Any Number , a Numerical Number , or Constant #Name of the Gadget )
  ET = EventType()         ;<<--- What sort of Event Type occurred
  AG = GetActiveGadget()   ;<<--- Get the Active Gadget's Numerical Number or Constant #Name that has the current Focus

  Select WW
  Case #PB_Event_Menu
       Select EM
       Case #KeyPageDown, #KeyReturn
             Select GetGadgetData(AG)
             Case 1 : SetActiveGadget(Combo_2)
             Case 2 : SetActiveGadget(Combo_3)
             Case 3 : SetActiveGadget(Combo_4)
             Case 4 : SetActiveGadget(Combo_1)
             EndSelect
       Case #KeyPageUp, #KeyEscape
             Select GetGadgetData(AG)
             Case 1 : SetActiveGadget(Combo_4)
             Case 2 : SetActiveGadget(Combo_1)
             Case 3 : SetActiveGadget(Combo_2)
             Case 4 : SetActiveGadget(Combo_3)
             EndSelect
       EndSelect
  EndSelect
Until WW = #PB_Event_CloseWindow : End
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Travel thru Gadgets

Post by VB6_to_PBx »

Travel thru Gadgets ( example 2)

Code: Select all

EnableExplicit

;- Global
Global.i Window_0
Global.i String_1
Global.i Combo_2
Global.i Combo_3
Global.i Combo_4
Global.i WW, EW, EM, EG, ET, AG   ;<<--- WW= WaitWindowEvent()  EW= EventWindow()  EM= EventMenu()  EG= EventGadget()  ET= EventType()  AG= GetActiveGadget()

;========================================================
;-[ Keyboard Shortcut Constants ]
;========================================================
#KeyReturn=10013 : #KeyEscape=10027 : #KeyPageUp=10033 : #KeyPageDown=10034 : #KeyEnd=10035 : #KeyHome=10036 : #KeyUp=10038 : #KeyDown=10040


;- Declare
Declare Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)

Procedure Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)
  Window_0 = OpenWindow(#PB_Any, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

  ;=====================================================================
  ;- Add Keyboard Shortcuts to travel thru Inputs
  ;=====================================================================
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Return,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Escape,#KeyEscape)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageDown,#KeyPageDown)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageUp,#KeyPageUp)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab | #PB_Shortcut_Shift,#KeyEscape)

  String_1 = StringGadget(#PB_Any, 128, 89, 144, 29,"String_1")
             SetGadgetData(String_1,1)

  Combo_4 = ComboBoxGadget(#PB_Any, 133, 247, 137, 31)  ;<<--- Combo_4 is out of desired Gadget travel Order
            AddGadgetItem(Combo_4, -1, "Combo_4")
            SetGadgetState(Combo_4, 0)
            SetGadgetData(Combo_4,4)

  Combo_2 = ComboBoxGadget(#PB_Any, 129, 147, 141, 27)
            AddGadgetItem(Combo_2, -1, "Combo_2")
            SetGadgetState(Combo_2, 0)
            SetGadgetData(Combo_2,2)

  Combo_3 = ComboBoxGadget(#PB_Any, 128, 198, 145, 27)
            AddGadgetItem(Combo_3, -1, "Combo_3")
            SetGadgetState(Combo_3, 0)
            SetGadgetData(Combo_3,3)

  SetActiveGadget(String_1)

EndProcedure

;- Main Program
Open_Window_0()

;- Event Loop
Repeat
  WW = WaitWindowEvent(10) ;<<--- Wait until a new Window or Gadget Event occurs.  ( 10 = the timeout in milliseconds or 1000 milliseconds = 1 second ) 
  EW = EventWindow()       ;<<--- In Programs with more than one Form or Window, which Window did the Event occur on
  EM = EventMenu()         ;<<--- Which Menu did the Event occur on
  EG = EventGadget()       ;<<--- Which Gadget did the Event occur on ( #PB_Any Number , a Numerical Number , or Constant #Name of the Gadget )
  ET = EventType()         ;<<--- What sort of Event Type occurred
  AG = GetActiveGadget()   ;<<--- Get the Active Gadget's Numerical Number or Constant #Name that has the current Focus

  Select WW
  Case #PB_Event_Menu
       Select EM
       Case #KeyPageDown, #KeyReturn
             Select GetGadgetData(AG)
             Case 1 : SetActiveGadget(Combo_2)
             Case 2 : SetActiveGadget(Combo_3)
             Case 3 : SetActiveGadget(Combo_4)
             Case 4 : SetActiveGadget(String_1)
             EndSelect
       Case #KeyPageUp, #KeyEscape
             Select GetGadgetData(AG)
             Case 1 : SetActiveGadget(Combo_4)
             Case 2 : SetActiveGadget(String_1)
             Case 3 : SetActiveGadget(Combo_2)
             Case 4 : SetActiveGadget(Combo_3)
             EndSelect
       EndSelect
  EndSelect
Until WW = #PB_Event_CloseWindow : End



 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Travel thru Gadgets

Post by VB6_to_PBx »

Travel thru Gadgets ( example 3)

Code: Select all

EnableExplicit

;- Global
Global.i Window_0
Global.i WW, EW, EM, EG, ET, AG   ;<<--- WW= WaitWindowEvent()  EW= EventWindow()  EM= EventMenu()  EG= EventGadget()  ET= EventType()  AG= GetActiveGadget()

;========================================================
;-[ Keyboard Shortcut Constants ]
;========================================================
#KeyReturn=10013 : #KeyEscape=10027 : #KeyPageUp=10033 : #KeyPageDown=10034 : #KeyEnd=10035 : #KeyHome=10036 : #KeyUp=10038 : #KeyDown=10040


;- Declare
Declare Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)

Procedure Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)
  Window_0 = OpenWindow(#PB_Any, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

  ;=====================================================================
  ;- Add Keyboard Shortcuts to travel thru Inputs
  ;=====================================================================
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Return,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Escape,#KeyEscape)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageDown,#KeyPageDown)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageUp,#KeyPageUp)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab | #PB_Shortcut_Shift,#KeyEscape)

  StringGadget(1, 128, 89, 144, 29,"String_1")

  ComboBoxGadget(4, 133, 247, 137, 31)  ;<<--- 4 is out of desired Gadget travel Order
            AddGadgetItem(4, -1, "Combo_4")
            SetGadgetState(4, 0)

  ComboBoxGadget(2, 129, 147, 141, 27)
            AddGadgetItem(2, -1, "Combo_2")
            SetGadgetState(2, 0)

  ComboBoxGadget(3, 128, 198, 145, 27)
            AddGadgetItem(3, -1, "Combo_3")
            SetGadgetState(3, 0)

  SetActiveGadget(1)

EndProcedure

;- Main Program
Open_Window_0()

;- Event Loop
Repeat
  WW = WaitWindowEvent(10) ;<<--- Wait until a new Window or Gadget Event occurs.  ( 10 = the timeout in milliseconds or 1000 milliseconds = 1 second ) 
  EW = EventWindow()       ;<<--- In Programs with more than one Form or Window, which Window did the Event occur on
  EM = EventMenu()         ;<<--- Which Menu did the Event occur on
  EG = EventGadget()       ;<<--- Which Gadget did the Event occur on ( #PB_Any Number , a Numerical Number , or Constant #Name of the Gadget )
  ET = EventType()         ;<<--- What sort of Event Type occurred
  AG = GetActiveGadget()   ;<<--- Get the Active Gadget's Numerical Number or Constant #Name that has the current Focus

  Select WW
  Case #PB_Event_Menu
       Select EM
       Case #KeyPageDown, #KeyReturn
             Select AG
             Case 1 : SetActiveGadget(2)
             Case 2 : SetActiveGadget(3)
             Case 3 : SetActiveGadget(4)
             Case 4 : SetActiveGadget(1)
             EndSelect
       Case #KeyPageUp, #KeyEscape
             Select AG
             Case 1 : SetActiveGadget(4)
             Case 2 : SetActiveGadget(1)
             Case 3 : SetActiveGadget(2)
             Case 4 : SetActiveGadget(3)
             EndSelect
       EndSelect
  EndSelect
Until WW = #PB_Event_CloseWindow : End






 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Travel thru Gadgets

Post by VB6_to_PBx »

Travel thru Gadgets ( example 4)

Code: Select all

EnableExplicit

;- Global
Global.i Window_0
Global.i WW, EW, EM, EG, ET, AG   ;<<--- WW= WaitWindowEvent()  EW= EventWindow()  EM= EventMenu()  EG= EventGadget()  ET= EventType()  AG= GetActiveGadget()

;========================================================
;-[ Keyboard Shortcut Constants ]
;========================================================
#KeyReturn=10013 : #KeyEscape=10027 : #KeyPageUp=10033 : #KeyPageDown=10034 : #KeyEnd=10035 : #KeyHome=10036 : #KeyUp=10038 : #KeyDown=10040


;- Declare
Declare Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)

Procedure Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)
  Window_0 = OpenWindow(#PB_Any, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

  ;=====================================================================
  ;- Add Keyboard Shortcuts to travel thru Inputs
  ;=====================================================================
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Return,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Escape,#KeyEscape)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageDown,#KeyPageDown)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageUp,#KeyPageUp)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab | #PB_Shortcut_Shift,#KeyEscape)

  StringGadget(1, 128, 89, 144, 29,"String_1")

  ComboBoxGadget(4, 133, 247, 137, 31)  ;<<--- 4 is out of desired Gadget travel Order
            AddGadgetItem(4, -1, "Combo_4")
            SetGadgetState(4, 0)

  ComboBoxGadget(2, 129, 147, 141, 27)
            AddGadgetItem(2, -1, "Combo_2")
            SetGadgetState(2, 0)

  ComboBoxGadget(3, 128, 198, 145, 27)
            AddGadgetItem(3, -1, "Combo_3")
            SetGadgetState(3, 0)

  SetActiveGadget(1)

EndProcedure

;- Main Program
Open_Window_0()

;- Event Loop
Repeat
  WW = WaitWindowEvent(10) ;<<--- Wait until a new Window or Gadget Event occurs.  ( 10 = the timeout in milliseconds or 1000 milliseconds = 1 second ) 
  EW = EventWindow()       ;<<--- In Programs with more than one Form or Window, which Window did the Event occur on
  EM = EventMenu()         ;<<--- Which Menu did the Event occur on
  EG = EventGadget()       ;<<--- Which Gadget did the Event occur on ( #PB_Any Number , a Numerical Number , or Constant #Name of the Gadget )
  ET = EventType()         ;<<--- What sort of Event Type occurred
  AG = GetActiveGadget()   ;<<--- Get the Active Gadget's Numerical Number or Constant #Name that has the current Focus

  Select WW
  Case #PB_Event_Menu
       Select EM
       Case #KeyPageDown, #KeyReturn
             Select AG
             Case 1 To 3 : SetActiveGadget(AG + 1)
             Case 4 : SetActiveGadget(1)
             EndSelect
       Case #KeyPageUp, #KeyEscape
             Select AG
             Case 1 : SetActiveGadget(4)
             Case 2 To 4 : SetActiveGadget(AG - 1)
             EndSelect
       EndSelect
  EndSelect
Until WW = #PB_Event_CloseWindow : End




 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Travel thru Gadgets

Post by VB6_to_PBx »

Travel thru Gadgets ( example 5)

Code: Select all

EnableExplicit

;- Global
Global.i Window_0
Global.i WW, EW, EM, EG, ET, AG   ;<<--- WW= WaitWindowEvent()  EW= EventWindow()  EM= EventMenu()  EG= EventGadget()  ET= EventType()  AG= GetActiveGadget()
Global.i Gad = 10                 ;<<--- Gad = Array contains the total number of User input Gadgets , such as :  StringGadgets and ComboBoxGadgets in GUI
Global.i Dim G(Gad)               ;<<--- G(Gad) Gadget's numerical numbering system using #PB_Any, SetGadgetData, and GetGadgetData for all User Inputs and Choices             

;========================================================
;-[ Keyboard Shortcut Constants ]
;========================================================
#KeyReturn=10013 : #KeyEscape=10027 : #KeyPageUp=10033 : #KeyPageDown=10034 : #KeyEnd=10035 : #KeyHome=10036 : #KeyUp=10038 : #KeyDown=10040

;- Declare
Declare Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)

Procedure Open_Window_0(X = 0, Y = 0, Width = 1160, Height = 764)
  Window_0 = OpenWindow(#PB_Any, X, Y, Width, Height, "Title", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

  ;=====================================================================
  ;- Add Keyboard Shortcuts to travel thru Inputs
  ;=====================================================================
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Return,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Escape,#KeyEscape)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageDown,#KeyPageDown)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_PageUp,#KeyPageUp)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab,#KeyReturn)
  AddKeyboardShortcut(Window_0,#PB_Shortcut_Tab | #PB_Shortcut_Shift,#KeyEscape)

  G(1) = StringGadget(#PB_Any, 128, 89, 144, 29,"String_1")
         SetGadgetData(G(1),1)

  G(4) = ComboBoxGadget(#PB_Any, 133, 247, 137, 31)  ;<<--- 4 is out of desired Gadget TAB Order
         AddGadgetItem(G(4), -1, "Combo_4")
         SetGadgetState(G(4), 0)
         SetGadgetData(G(4),4)

  G(2) = ComboBoxGadget(#PB_Any, 129, 147, 141, 27)
         AddGadgetItem(G(2), -1, "Combo_2")
         SetGadgetState(G(2), 0)
         SetGadgetData(G(2),2)

  G(3) = ComboBoxGadget(#PB_Any, 128, 198, 145, 27)
         AddGadgetItem(G(3), -1, "Combo_3")
         SetGadgetState(G(3), 0)
         SetGadgetData(G(3),3)

  SetActiveGadget(G(1))

EndProcedure

;- Main Program
Open_Window_0()

;- Event Loop
Repeat
  WW = WaitWindowEvent(10) ;<<--- Wait until a new Window or Gadget Event occurs.  ( 10 = the timeout in milliseconds or 1000 milliseconds = 1 second ) 
  EW = EventWindow()       ;<<--- In Programs with more than one Form or Window, which Window did the Event occur on
  EM = EventMenu()         ;<<--- Which Menu did the Event occur on
  EG = EventGadget()       ;<<--- Which Gadget did the Event occur on ( #PB_Any Number , a Numerical Number , or Constant #Name of the Gadget )
  ET = EventType()         ;<<--- What sort of Event Type occurred
  AG = GetActiveGadget()   ;<<--- Get the Active Gadget's Numerical Number or Constant #Name that has the current Focus

  Select WW
  Case #PB_Event_Menu
       Select EM
       Case #KeyPageDown, #KeyReturn
             Select GetGadgetData(AG)
             Case 1 To 3 : SetActiveGadget(G(GetGadgetData(AG) + 1))
             Case 4 : SetActiveGadget(G(1))
             EndSelect
       Case #KeyPageUp, #KeyEscape
             Select GetGadgetData(AG)
             Case 1 : SetActiveGadget(G(4))
             Case 2 To 4 : SetActiveGadget(G(GetGadgetData(AG) - 1))
             EndSelect
       EndSelect
  EndSelect
Until WW = #PB_Event_CloseWindow : End







 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
Post Reply