ButtonGadget()

Syntax

Result = ButtonGadget(#Gadget, x, y, Width, Height, Text$ [, Flags])
Description
Create a button gadget in the current GadgetList.

Parameters

#Gadget A number to identify the new gadget. #PB_Any can be used to auto-generate this number.
x, y, Width, Height The position and dimensions of the new gadget.
Text$ The text to display on the button.
Flags (optional) A combination (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.

Return value

Returns nonzero on success and zero on failure. If #PB_Any was used as the #Gadget parameter then the return-value is the auto-generated gadget number on success.

Remarks

A 'mini help' can be added to this gadget using GadgetToolTip().

The following functions can be used to control the gadget:

- SetGadgetText(): Changes the text of the ButtonGadget.
- GetGadgetText(): Returns the text of the ButtonGadget.
- SetGadgetState(): Used with #PB_Button_Toggle buttons to set the actual state (1 = toggled, 0 = normal).
- GetGadgetState(): Used with #PB_Button_Toggle buttons to get the actual state of the button (1 = toggled, 0 = normal).

Example

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

See Also

SetGadgetText(), GetGadgetText(), SetGadgetState(), GetGadgetState(), ButtonImageGadget()
<- BindGadgetEvent() - Gadget Index - ButtonImageGadget() ->