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 number will be returned as 'Result'. #Gadget will be the number returned by EventGadget() 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.
You can add a 'mini help' to this gadget by using GadgetToolTip().

Special Windows feature:
In the button 'Text$' you can use the special '&' character to underline a specific letter: "&Button" will give in reality : Button
(Note: under Windows XP the underlined letter will only be displayed if this is not deactivated in the system settings.)

In combination with the AddKeyboardShortcut() command a keyboard shortcut for the button can be realized this way.

Example:
  ; Shows possible flags of ButtonGadget in action...
  If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 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

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