ButtonGadget()

Syntax

Result = ButtonGadget(#Gadget, x, y, Width, Height, Text$ [, Flags])
Description
Create a button gadget in the current GadgetList. If #PB_Any is used as '#Gadget' parameter, the new gadget identifier will be returned as 'Result'. #Gadget will be the number returned by EventGadgetID() command.

'Flags' are always optional and can be composed of one or several (using the bitwise OR operator '|') of the following constants:
  #PB_Button_Right     : Aligns the button text at the right.
  #PB_Button_Left      : Aligns the button text at the left.
  #PB_Button_Default   : Makes the button look as if it is the default button in the window.
  #PB_Button_MultiLine : If the text is too long, it will be displayed on several lines.
  #PB_Button_Toggle    : Creates a toggle button: one click pushes it, another will release it.
The following EventType() are supported by ButtonGadget() if AdvancedGadgetEvents() is enabled before the gadget creation.
  #PB_EventType_LeftClick         :  Left  mouse button click.
  #PB_EventType_RightClick        :  Right mouse button click.
  #PB_EventType_LeftDoubleClick   :  Left  mouse button double click.
  #PB_EventType_RightDoubleClick  :  Right mouse button double click.
  #PB_EventType_Focus             :  Button got  the focus for input.
  #PB_EventType_LostFocus         :  Button lost the focus for input.
You can add a 'mini help' to this gadget by using GadgetToolTip().

Example:
  ; Shows possible flags of ButtonGadget in action...
  If OpenWindow(0,0,0,222,200,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ButtonGadgets") And CreateGadgetList(WindowID(0))
    ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
    ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left)
    ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right)
    ButtonGadget(3, 10,100, 200, 60, "Multiline Button  (longer text gets automatically wrapped)", #PB_Button_MultiLine)
    ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle)
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
  EndIf

Supported OS

All

<- AdvancedGadgetEvents() - Gadget Index - ButtonImageGadget() ->