handle event inside a Cell of a CellTree

300 views
Skip to first unread message

lamre

unread,
Apr 14, 2011, 5:51:52 AM4/14/11
to Google Web Toolkit
Hi, i want a cell to handle an event(double click) but i am having
problems on making it work.
I was trying to insert to handle this event overriding onBrowserEvent
and make different actions based on event
type. I don't now what the problem but it doesn't work.
Thanks.

Cell<Node> cell = new AbstractCell<Node>()
{
@Override
public void render(Context context, Node value, SafeHtmlBuilder
sb)
{
if (value != null) { sb.appendEscaped(value.getNodeName()
+"ermal"); }
}
@Override
public void onBrowserEvent(Context context, Element parent, Node
value,
NativeEvent event, ValueUpdater<Node> valueUpdater)
{

if (value == null) { return; }
super.onBrowserEvent(context, parent, value, event,
valueUpdater);

if(Integer.parseInt(event.getType())==Event.ONDBLCLICK)
{
ControllerPqm.getInstance().advise(ControllerPqm.ADVISE_ERROR,
"Chick");
}
}
};

Thomas Broyer

unread,
Apr 14, 2011, 6:48:06 AM4/14/11
to google-we...@googlegroups.com
You have to pass "dblclick" to the AbstractCell constructor, or "dblclick" events won't be routed to your cell.

new AbstractCell<Node>("dblclick") { ... }

You can also use DoubleClickEvent.getType().getName() instead of the "dblclick" constant if you prefer.

And of course, event.getType() returns "dblclick", so your Integer.parseInt() fails. Either do a String comparison with "dblclick", or use Event.getTypeInt(event.getType()) to turn it into something that can be compared with Event.ONDBLCLICK.

lamre

unread,
Apr 14, 2011, 7:49:58 AM4/14/11
to Google Web Toolkit
Thanks

lamre

unread,
Apr 27, 2011, 9:40:11 AM4/27/11
to Google Web Toolkit
Hi, i have a problem on adding "dblclick" event when extending
AbstractCell.
This way works:

Cell<Folder> cell = new AbstractCell<Folder>("dblclick")
{....}

But when i try to create a class i have an error:"Syntax error on
tokens, AnnotationName expected instead"

private static class CartellaCell extends AbstractCell<Cartella>
("dblclick")
{....}

Any idea. Thanks


private static class CartellaCell extends AbstractCell<Cartella>

On 14 Apr, 13:49, lamre <erm...@gmail.com> wrote:
> Thanks
Reply all
Reply to author
Forward
0 new messages