java-gnome version 4.0.19

org.gnome.gtk
Interface Widget.ScrollEvent

Enclosing class:
Widget

public static interface Widget.ScrollEvent

Signal emitted when the user turns the mouse wheel.

In most cases you are not interested in this Signal. If you only want to provide a Scrolling surface for a big Widget, ScrolledWindow is what you are looking for.

This event can be useful, however, when you want to have more control of the scroll operations, specially when implemented custom Widgets.

For example, to implement a zoom operation when the user turns the mouse wheel while pressing the Ctrl key, as many drawing applications do:

 MyCustomWidget w;
 
 w.connect(new Widget.ScrollEvent() {
     public boolean onScrollEvent(Widget source, EventScroll event) {
         // check if Ctrl key is pressed
         if (event.getState().contains(ModifierType.CONTROL_MASK)) {
             ScrollDirection dir = event.getDirection();
             if (dir == ScrollDirection.UP) {
                 // increment zoom
             } else if (dir == ScrollDirection.DOWN) {
                 // decrement zoom
             }
             // prevent the default scrolling if the Widget is added
             // to a ScrolledWindow 
             return true;
         }
         return false;
     }
 });
 

It is also useful when your custom Widget can use the scroll events to perform some related operation. For example, when you scroll a ComboBox Widget it changes its active item. Of course, this is only useful when the operation can be seen as a scroll in the particular Widget context; it is not a good idea, for example, to close a Window or click a Button in response to a Widget.SrollEvent.

Since:
4.0.12
Author:
Vreixo Formoso

Method Summary
 boolean onScrollEvent(Widget source, EventScroll event)
           
 

Method Detail

onScrollEvent

boolean onScrollEvent(Widget source,
                      EventScroll event)


java-gnome