tags:

views:

37

answers:

1

Hi everybody,I wrote a widget like this:

public class GroupLbl extends Composite implements ClickHandler, MouseOutHandler {
private Label lbl;
private GroupLblHandler lblHandler = null;
private HorizontalPanel hp;

public void onClick(ClickEvent event) {
    hp.setStyleName("background-GroupLbl");

    if (event.getSource().equals(folder) || event.getSource().equals(lbl)) {

     lblHandler.onGroupLabelSelect(this);
 }
}

public GroupLbl(String title, GroupLblHandler handler) {

    hp.add(lbl);
    lblHandler = handler;
    if (handler != null) {
        lbl.addClickHandler(this);

    }
    initWidget(hp);
}


@Override
public Widget getWidget() {
    return hp;
}



public void onMouseOut(MouseOutEvent event) {
    hp.removeStyleName("background-GroupLbl");
}

} I use this widget in my form,when the user click on one of INSTANCE of widget the stylename should be assign to this and when the user click on other the stylename should assign to that and the first shoud remove the style name I implemented mouseouthandler but it doese not work,the style set the bgcolor to hp so the user understand which grouplbl he/she has selected.what shoul I do(It is part of my code)? tnx and excuse me for my bad english !!!

+3  A: 

Define an additional CSS style with suffix -background with the bg color you wish to have. Instead of setStyleName use addStyleDependentName( "background" ) along with removeStyleDependentName( "background" ) to add/remove -background style.

Ashwin Prabhu