user123456789
user123456789

Reputation: 41

auto hidden layout in vaadin

i want to make a layout that be visible on mouse over and hide automatically on mouse out. i try this code but it not give me any result;

public class DemoLayout extends VerticalLayout implements MouseOverHandler,
        MouseOutHandler,MouseUpHandler {

    /**
     * 
     */
    private static final long serialVersionUID = 7610044813670041530L;

    public DemoLayout() {
        super();
    }

    @Override
    public void onMouseOver(MouseOverEvent event) {
        // TODO Auto-generated method stub
        System.out.println("Mouse over");
    }

    @Override
    public void onMouseOut(MouseOutEvent event) {
        // TODO Auto-generated method stub
        System.out.println("Mouse out");
    }

    @Override
    public void onMouseUp(MouseUpEvent event) {
        // TODO Auto-generated method stub
        System.out.println("Mouse up");
    }
}

vaadin doesn't support layout mouse listener? how can i implement this feature? thank you

Upvotes: 2

Views: 619

Answers (2)

Henri Kerola
Henri Kerola

Reputation: 4967

You have two options:

  1. Depending on your exact use case, you could probably just use CSS and the :hover pseudo class.

  2. If :hover doesn't work then you could use the excellent Mouse Event Extension addon.

Upvotes: 1

Morfic
Morfic

Reputation: 15528

I may be wrong, but I don't know of such listeners for layouts up to Vaadin 7.4.3. The good news is that you have at least a few options:

  1. the handlers you're implementing are from com.google.gwt.event.dom.client package which is bundled in the vaadin-client jar. You're, probably unintentionally, mixing client-side & server-side classes which is most likely not what you're after. However you can try to create your own widget and implement those handlers on the client side as suggested here and/or here
  2. you may be able use the CSS :hover pseudo-class to some degree as discussed here
  3. (perhaps the simplest) you could achieve a similar effect with a click. Take a look at the SliderPanel add-on to avoid re-inventing the wheel

Upvotes: 1

Related Questions