org.gnome.gtk

## Interface Button.Clicked

- Enclosing class:
    Button

      public static interface Button.Clicked

  Event generated when a user presses and releases a button, causing it to activate.

  When the mouse is used to click on a Button this signal will be emitted, but only if the cursor is still in the Button when the mouse button is released. You're probably used to this behaviour without realizing it.

  ## All about signal handling

  ### Use an anonymous inner class

  In general, the way that java-gnome is intended to be used is for you to create an anonymous inner class right where you call the `connect()` method to hook up the signal. A typical example is as follows:

       final Button b;

       b.connect(new Button.Clicked() {
           public void onClicked(Button source) {
               doSomething();
           }
       }

  This is the form we recommend; it has the advantage that your handler code is close to the code that declares and configures the Widget. Also, if variables are declared `final` then you can access them from within the nested anonymous class, and that makes things easy indeed.

  ### Using a concrete instance

  If you have more complex code, perhaps that you need to reuse across several Widgets, then you can of course create a concrete class that implements Button.Clicked and then use instances of it if you have highly complicated algorithms to implement:

       class ComplexHandler implements Button.Clicked
       {
           private int field;

           ComplexHandler(int param) {
               this.field = param;
           }

           public void onClicked(Button source) {
               doSomethingVeryComplicatedWith(field);
           }
       }

  and then when you construct the Button:

       b = new Button();
       b.connect(new ComplexHandler(42));

  You can just as easily declare one and reuse it if you want to apply the same logic to a series of Button; this is where the `source` parameter that every signal callback signature includes.

       final ComplexHandler handler;

       handler = new ComplexHandler(42);
       ...
       b1.connect(handler);
       b2.connect(handler);
       b3.connect(handler);
       ...

  ### Self-delegation

  If you implement Button.Clicked in the class you're currently working on, then you use a technique called "self-delegation" which can be useful in certain circumstances:

       b.connect(this);

  This has disadvantage that you can only have one `onClicked()` method in your class, so if you have lots of Buttons then you lose the benefit of being able to connect different handlers to different Buttons.

  We recommend you use anonymous inner classes in-place whenever possible. In our experience, having the handler logic next to the code that declares an instance dramatically improves readability.

  Since:
    4.0.0
  Author:
    Andrew Cowie

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `onClicked(Button source)`

- - ### Method Detail

    - #### onClicked

          void onClicked(Button source)