GetActiveGadget()

Syntax

Result = GetActiveGadget()
Description
Returns the gadget number of the Gadget that currently has the keyboard focus.

Parameters

None.

Return value

Returns the #Gadget number of the Gadget with the focus. If no Gadget has the focus, -1 is returned.

Example

  If OpenWindow(0, 0, 0, 270, 70, "GetActiveGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    StringGadget  (0, 10, 10, 250, 20, "Press escape...")
    StringGadget  (1, 10, 40, 250, 20, "Press escape...")
    AddKeyboardShortcut(0, #PB_Shortcut_Escape, 1)
    SetActiveGadget(0)
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Menu And EventMenu() = 1
        MessageRequester("Test", "Escape pressed in Gadget " + Str(GetActiveGadget()))
      EndIf
    Until Event = #PB_Event_CloseWindow
  EndIf

Supported OS

All

<- GadgetY() - Gadget Index - GetGadgetAttribute() ->