Roughian Examples Site Map - GWT Examples - Tutorials

PushButton


Version 1.4 onwards

The PushButton is a styleable button



Listeners


Notes


The PushButton is a really handy little thing. It is styleable, you can give it two lots of text, one for the up-state, one for the down-state. Or you can do the same with two images.

It doesn't have a mouse listener unfortunately, which is odd, but they make up for it with css styles. But...


Problem


The PushButton styles let you determine the look for (when enabled) 'up', 'up-hovering', 'down', 'down, hovering' - so you can't get a button-is-being-pushed look. If you try the menu buttons on this site you get a look if you are actually pressing the button. You can't get that with this widget.


Code


PushButton widget = new PushButton("Click Me", "Get Off!");
widget.setStylePrimaryName("demo-PushButton");


CSS


/***********************************************************
*                         PushButton Demo
***********************************************************/
.demo-PushButton
{
    border                      :   1px solid #666;
    margin                      :   3px 1px;
    font-size                   :   80%;
    cursor                      :   hand;
    cursor                      :   pointer;
    background-color            :   #ff0;
    padding                     :   0 10px;
}
.demo-PushButton-down-hovering
{
    background-color            :   #ccf;
}
.demo-PushButton-up-hovering
{
    background-color            :   #0f0;
}