When you say a second later, are you moving the mouse? I.e., if you click on the row and leave the mouse cursor there (try taking your hand off the mouse) does it still revert back?
If you're moving the mouse, what's probably happening is that the onMouseOut or focus/blur events are being fired which is causing the color change.
Depending on the type of cell you're rendering, you want to override the onBrowserEvent(...) method and listen for the appropriate event and apply the style you want. Here's an example we've done for mouse events:
Code:
@Override
public void onBrowserEvent(Context context, Element parent, AssetBean value, NativeEvent event, ValueUpdater<AssetBean> valueUpdater) {
String eventType = event.getType();
XElement p = parent.cast();
if ("mouseover".equals(eventType)) {
onMouseOver(p);
}
else if ("mouseout".equals(eventType)) {
onMouseOut(p);
}
}
protected static void onMouseOut(XElement p) {
p.addClassName("cursor-default");
p.removeClassName("cursor-pointer");
}
protected static void onMouseOver(XElement p) {
p.removeClassName("cursor-default");
p.addClassName("cursor-pointer");
}
If you do wind up constructing your own cell, make sure you pass to super(...) the events to which you want to subscribe or you won't get them:
Code:
import com.google.gwt.cell.client.AbstractCell;
public class MyCell extends AbstractCell<MyBean>
{
public MyCell()
{
super("click", "keydown", "mouseover", "mouseout");
}
*** snip ***
I would caution against using this approach for the entire row however. If you're looking for a more thorough answer that applies to the row, the GXT devs hang out in #extgwt on Freenode IRC.