SetActiveGadget()

Syntax

SetActiveGadget(#Gadget)
Description
Activates (sets the focus on) the gadget specified by the given #Gadget number. This is mainly used with ComboBoxGadget() and StringGadget(). Activating a gadget allows it to become the current object to receive messages and handle keystrokes.

Example:
  If OpenWindow(0, 0, 0, 270, 140, "SetActiveGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    StringGadget  (0, 10, 10, 250, 20, "bla bla...")
    ComboBoxGadget(1, 10, 40, 250, 100)
    For a = 1 To 5 : AddGadgetItem(1, -1, "ComboBox item " + Str(a)) : Next
    SetGadgetState(1, 2)                ; set (beginning with 0) the third item as active one
    ButtonGadget  (2, 10,  90, 250, 20, "Activate StringGadget")
    ButtonGadget  (3, 10, 115, 250, 20, "Activate ComboBox")
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Gadget
        Select EventGadget()
          Case 2 : SetActiveGadget(0)   ; Activate StringGadget
          Case 3 : SetActiveGadget(1)   ; Activate ComboBoxGadget
        EndSelect
      EndIf
    Until Event = #PB_Event_CloseWindow
  EndIf

Supported OS

All

<- ScrollBarGadget() - Gadget Index - SetGadgetAttribute() ->