[Contents] [Back] [Prev] [Up] [Next] [Forward]

# Package Gtk.Button

This package implements a general button widget. This button can be clicked on by the user to start any action. This button does not have multiple states, it can just be temporarily pressed while the mouse is on it, but does not keep its pressed state.

The gtk+ sources provide the following drawing that explains the role of the various spacings that can be set for a button:

     +------------------------------------------------+
     |                   BORDER                       |
     |  +------------------------------------------+  |
     |  |\\\\\\\\\\\\\\\\DEFAULT\\\\\\\\\\\\\\\\\  |  |
     |  |\\+------------------------------------+  |  |
     |  |\\| |           SPACING       3      | |  |  |
     |  |\\| +--------------------------------+ |  |  |
     |  |\\| |########## FOCUS ###############| |  |  |
     |  |\\| |#+----------------------------+#| |  |  |
     |  |\\| |#|         RELIEF            \|#| |  |  |
     |  |\\| |#|  +-----------------------+\|#| |  |  |
     |  |\\|1|#|  +     THE TEXT          +\|#|2|  |  |
     |  |\\| |#|  +-----------------------+\|#| |  |  |
     |  |\\| |#| \\\\\ ythickness \\\\\\\\\\|#| |  |  |
     |  |\\| |#+----------------------------+#| |  |  |
     |  |\\| |########### 1 ##################| |  |  |
     |  |\\| +--------------------------------+ |  |  |
     |  |\\| |        default spacing   4     | |  |  |
     |  |\\+------------------------------------+  |  |
     |  |\            ythickness                   |  |
     |  +------------------------------------------+  |
     |                border_width                    |
     +------------------------------------------------+

- Gtk.Button Widget Hierarchy
- Gtk.Button Signals
- Gtk.Button Subprograms
- Gtk.Button Example

## Widget Hierarchy

    GObject                       (see section Package Glib.Object)
    Gtk_Object                    (see section Package Gtk.Object)
       \___ Gtk_Widget            (see section Package Gtk.Widget)
          \___ Gtk_Container      (see section Package Gtk.Container)
             \___ Gtk_Bin         (see section Package Gtk.Bin)
                \___ Gtk_Button   (see section Package Gtk.Button)

## Signals

- "clicked" procedure Handler (Button : access Gtk_Button_Record'Class);
  Emitted when the button has been clicked on by the user. This is the signal you should use to start your own actions.
- "enter" procedure Handler (Button : access Gtk_Button_Record'Class);
  Emitted when the mouse enters the button. The clicked signal can only be emitted when the mouse is inside the button.
- "leave" procedure Handler (Button : access Gtk_Button_Record'Class);
  Emitted when the mouse leaves the button.
- "pressed" procedure Handler (Button : access Gtk_Button_Record'Class);
  Emitted when the user presses the mouse button on the widget. The default implementation modifies the widget state and its visual aspect.
- "released" procedure Handler (Button : access Gtk_Button_Record'Class);
  Emitted when the user releases the mouse button and is inside of the widget. The default implementation modifies the widget state and its visual aspect. If the mouse is still inside the widget, then the "clicked" signal is emitted.

## Subprograms

    procedure Gtk_New
      (Button             : out    Gtk_Button;
       Label              :        UTF8_String := "");

| Create a new button. if Label is not the empty string, then the text appears in the button (and the child of the button is a Gtk_Label). On the other hand, if Label is the empty string, then no child is created for the button and it is your responsibility to add one. This is the recommended way to put a pixmap inside the button.

    procedure Gtk_New_From_Stock
      (Button             : out    Gtk_Button;
       Stock_Id           :        String);

| Create a new button containing the image and text from a stock item. Some stock ids have predefined contants like Gtk.Stock.Stock_OK or Gtk.Stock.Stock_Apply. See Gtk.Stock for a complete list of predefined stock items. Stock_Id: the name of the stock item.

    procedure Gtk_New_With_Mnemonic
      (Button             : out    Gtk_Button;
       Label              :        UTF8_String);

| Create a new button containing a label. Label: The text of the button, with an underscore in front of the mnemonic character If characters in Label are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.

    procedure Initialize_From_Stock
      (Button             : access Gtk_Button_Record'Class;
       Stock_Id           :        String);

| Internal initialization function.

    procedure Initialize_With_Mnemonic
      (Button             : access Gtk_Button_Record'Class;
       Label              :        UTF8_String);

| Internal initialization function.

    function Get_Type              return Gtk.Gtk_Type;

| Return the internal value associated with a Gtk_Button.

    procedure Set_Relief
      (Button             : access Gtk_Button_Record;
       New_Style          :        Gtk.Enums.Gtk_Relief_Style);

| Modify the relief style for the button. This modifies only its visual aspect, not its behavior.

    function Get_Relief
      (Button             : access Gtk_Button_Record)
       return Gtk.Enums.Gtk_Relief_Style;

| Get the current relief style for the button

    procedure Set_Label
      (Button             : access Gtk_Button_Record;
       Label              :        UTF8_String);

| Set the label of the button.

    function Get_Label
      (Button             : access Gtk_Button_Record)
       return UTF8_String;

| Return the label of the button.

    procedure Set_Use_Underline
      (Button             : access Gtk_Button_Record;
       Use_Underline      :        Boolean);

| Set whether underscore is used to designate an accelerator.

    function Get_Use_Underline
      (Button             : access Gtk_Button_Record)
       return Boolean;

| Return whether underscores are used to designate an accelerator.

    procedure Set_Use_Stock
      (Button             : access Gtk_Button_Record;
       Use_Stock          :        Boolean);

| Set whether a stock item is used by the button.

    function Get_Use_Stock
      (Button             : access Gtk_Button_Record)
       return Boolean;

| Return whether a stock item is used by the button.

### Signals emission

    procedure Pressed
      (Button             : access Gtk_Button_Record);

| Send the "pressed" signal to the button

    procedure Released
      (Button             : access Gtk_Button_Record);

| Send the "release" signal to the button

    procedure Clicked
      (Button             : access Gtk_Button_Record);

| Send the "clicked" signal to the button

    procedure Enter
      (Button             : access Gtk_Button_Record);

| Send the "enter" signal to the button

    procedure Leave
      (Button             : access Gtk_Button_Record);

| Send the "leave" signal to the button

## Example

     +------------------------------------------------+
     |                   BORDER                       |
     |  +------------------------------------------+  |
     |  |\\\\\\\\\\\\\\\\DEFAULT\\\\\\\\\\\\\\\\\  |  |
     |  |\\+------------------------------------+  |  |
     |  |\\| |           SPACING       3      | |  |  |
     |  |\\| +--------------------------------+ |  |  |
     |  |\\| |########## FOCUS ###############| |  |  |
     |  |\\| |#+----------------------------+#| |  |  |
     |  |\\| |#|         RELIEF            \|#| |  |  |
     |  |\\| |#|  +-----------------------+\|#| |  |  |
     |  |\\|1|#|  +     THE TEXT          +\|#|2|  |  |
     |  |\\| |#|  +-----------------------+\|#| |  |  |
     |  |\\| |#| \\\\\ ythickness \\\\\\\\\\|#| |  |  |
     |  |\\| |#+----------------------------+#| |  |  |
     |  |\\| |########### 1 ##################| |  |  |
     |  |\\| +--------------------------------+ |  |  |
     |  |\\| |        default spacing   4     | |  |  |
     |  |\\+------------------------------------+  |  |
     |  |\            ythickness                   |  |
     |  +------------------------------------------+  |
     |                border_width                    |
     +------------------------------------------------+

[Contents] [Back] [Prev] [Up] [Next] [Forward]