SetActiveGadget()

Syntax

SetActiveGadget(#Gadget)
Description
Activates (sets the keyboard focus on) the gadget specified by the given gadget number. Activating a gadget allows it to become the current object to receive messages and handle keystrokes.

Parameters

#Gadget The gadget to activate.

Return value

None.

Example

  Procedure ActivateStringGadgetEvent()
    SetActiveGadget(0)   ; Activate StringGadget
  EndProcedure
  
  Procedure ActivateComboBoxGadgetEvent()
    SetActiveGadget(1)   ; Activate ComboBoxGadget
  EndProcedure
  
  If OpenWindow(0, 0, 0, 270, 140, "SetActiveGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    StringGadget  (0, 10, 10, 250, 20, "bla bla...")
    ComboBoxGadget(1, 10, 40, 250, 21)
    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")
    
    BindGadgetEvent(2, @ActivateStringGadgetEvent())
    BindGadgetEvent(3, @ActivateComboBoxGadgetEvent())
  EndIf

See Also

GetActiveGadget(), SetActiveWindow()
<- ScrollAreaGadget() - Gadget Index - SetGadgetAttribute() ->