gwtbootstrap / gwt-bootstrap

A GWT Library that provides the widgets of Bootstrap, from Twitter.
http://gwtbootstrap.github.com
405 stars 190 forks source link

Dropdown menus - Show on hover: Java code #364

Open jkrogsboell opened 11 years ago

jkrogsboell commented 11 years ago

Issue #222 has been closed 17 days ago.

This code is working fine for me - perhaps it could be merged into the dropdown class:

//Dropdown on hover in Navbars
class MenuDropdown extends Dropdown {
    public MenuDropdown(String text) {
        super(text);

        this.addDomHandler(new MouseOverHandler() {
            @Override
            public void onMouseOver(MouseOverEvent event) {
                MenuDropdown.this.getElement().addClassName("open");
            }

        }, MouseOverEvent.getType());

        this.addDomHandler(new MouseOutHandler() {
            @Override
            public void onMouseOut(MouseOutEvent event) {
                MenuDropdown.this.getElement().removeClassName("open");
            }

        }, MouseOutEvent.getType());

        //Inserting a panel to fill the gap between the link and the popup 
        //and avoid a premature MouseOutEvent
        AbsolutePanel abs = new AbsolutePanel();
        abs.setHeight("2px");
        abs.setWidth("100%");
        abs.getElement().getStyle().setPosition(Position.ABSOLUTE);
//      abs.getElement().getStyle().setBackgroundColor("red");
        this.getElement().appendChild(abs.getElement() );

    }
}
caarlos0 commented 11 years ago

Perhaps you could do a pull request with this code in a separated dropdown class, something like HoverMenuDropdown?

Thanks!

jkrogsboell commented 11 years ago

Hi Carlos,

I will do that when I've got the time (got to learn how the github repo works too).

Anyway: Thank you for this gwt port of bootstrap, it's really moving our gwt project forward.

/Jonas

2013/5/24 Carlos Alexandro Becker notifications@github.com

Perhaps you could do a pull request with this code in a separated dropdown class, something like HoverMenuDropdown?

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/gwtbootstrap/gwt-bootstrap/issues/364#issuecomment-18400355 .

Jonas Krogsbøll Tlf: 28 84 10 26

caarlos0 commented 11 years ago

You're welcome!

I'll close this issue for now!

Cheers