If you need this just for the highlight, simply use CSS to specify
:hover appearance.
--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com
> Unfortunately, most versions of IE only support :hover on <A> elements, IIRC.
>
So, what can i do to hightlinght the row on any browser ?
final FlexTable f = new FlexTable();
for(int y = 0 ;y<3;y++)
{
for(int x = 0 ;x<3;x++)
{
final HTML h = new HTML("Hello");
final int z = y;
h.addMouseListener
(new MouseListener(){
public void onMouseDown(Widget sender, int x, int y)
{
}
public void onMouseEnter(Widget sender)
{
f.getRowFormatter().setStyleName(z, "mo");
}
public void onMouseLeave(Widget sender)
{
f.getRowFormatter().removeStyleName(z, "mo");
}
public void onMouseMove(Widget sender, int x, int y)
{
}
public void onMouseUp(Widget sender, int x, int y)
{
}});
f.setWidget(y, x, h);
}
add(f);
//--------------- begin snippet
public class MyTable extends FlexTable {
public MyTable() {
super();
// indicate which events you intend to notice
sinkEvents(Event.ONMOUSEDOWN | Event.ONMOUSEUP | Event.ONMOUSEOVER |
Event.ONMOUSEOUT);
}
public void onBrowserEvent(Event event) {
Element td = getEventTargetCell(event);
if (td == null) return;
Element tr = DOM.getParent(td);
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEDOWN: {
DOM.setStyleAttribute(tr, "backgroundColor", "#ffce00");
onRowClick(tr);
break;
}
case Event.ONMOUSEUP: {
DOM.setStyleAttribute(tr, "backgroundColor", "#ffffff");
break;
}
case Event.ONMOUSEOVER: {
DOM.setStyleAttribute(tr, "backgroundColor", "#ffce00");
onRowRollover(tr);
break;
}
case Event.ONMOUSEOUT: {
DOM.setStyleAttribute(tr, "backgroundColor",
"#ffffff");
break;
}
}
}
}
//--------------- end snippet
I hope that is helpful.
I gona try it ;)