Hi All,
Iam working on onCellClicked() method of
FlexTable(com.google.gwt.user.client.ui.FlexTable) cell in GWT.Now my
requirement is i have to change the color of flextable cell into green color
when i perform single click and change the color to yellow when i perform
double click on the cell of an flextable.
To perform doubleclick on flexTable cell i wrote a class
FlextableCatchDoubleClick but it is accepting single click only.
the code is as follows:
package com.mymdworld.client.utils;
import java.util.Iterator;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
import com.google.gwt.user.client.ui.TableListenerCollection;
public class FlextableCatchDoubleClick extends FlexTable implements
SourcesTableEvents {
private TableListenerCollection tableListeners;
public FlextableCatchDoubleClick(){
super();
this.sinkEvents(Event.ONDBLCLICK | Event.ONCLICK);
}
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
Element td = getEventTargetCell(event);
if (td == null) {
return;
}
Element tr = DOM.getParent(td);
Element body = DOM.getParent(tr);
int row = DOM.getChildIndex(body, tr);
int column = DOM.getChildIndex(tr, td);
int type = DOM.eventGetType(event);
switch (type) {
case Event.ONDBLCLICK: {
if (tableListeners != null) {
tableListeners.fireCellClicked(this,row,column);
}
break;
}
case Event.ONCLICK: {
if (tableListeners != null) {
tableListeners.fireCellClicked(this,row,column);
}
break;
}
}
}
public void addTableListener(TableListener arg0){
if (tableListeners == null)
tableListeners = new TableListenerCollection();
tableListeners.add(arg0);
}
public void removeTableListener(TableListener arg0)
{
if (tableListeners != null)
tableListeners.remove(arg0);
}
}
In another class iam creating an object of this class and writing
clicklistener for it as:
FlextableCatchDoubleClick table1=new FlextableCatchDoubleClick ();
table1.addTableListener(new TableListener(){
public void onCellClicked(SourcesTableEvents arg0,
int arg1, int arg2) {
-------------
--------------------
}
});
How can i differentiate between singleClick and doubleClick of the FlexTable
cell.
Please can anyone help me...
Thanks In Advance....
Swathi.K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---