I need to implement in some text field the possibility to double click (or any other way) and open a popup window containing an editor (e.g. but not only an html text editor).
Could someone suggest the way ?
I wasn’t able to find a double click listener/method for TextFields/TextAreas.
Tks
Tullio
Hi!
One solution could be to create an extension for components that needs to listen for double clicks.
First, if you don’t know how to create extensions,
read this
What you essentially want to do in the Connector of your extension is to listen for double clicks for your extended widget:
In your connector’s extend()-method, add something like this
extendedWidget.addDomHandler(new DoubleClickHandler() {
@Override
public void onDoubleClick(DoubleClickEvent event) {
// Here, send a click by using RPC to the server
}
}, DoubleClickEvent.getType());
Send an event (using RPC) to the server that a double click has been executed. If Vaadin & RPC is not familiar,
read this tutorial
.
However, if you are using the Vaadin Eclipse plugin, you can get the widget stubs handily and just add/remove stuff you need.
Hope this helps.
// Johan
Alternatively, you should be able to able to add a
LayoutClickListener
to the layout containing the field - this way you can avoid client-side programming, if you wish. (I think all of the core Vaadin layouts extend AbstractLayout which implement LayoutEvents.LayoutClickNotifier => You can add a LayoutClickListener to any layout. Of course, if the component itself swallows the click event, then the LayoutClickEvent won’t be generated. Shouldn’t be an issue here, though)
Johan’s approach is better IMHO, but a LayoutClickListener should be relatively quick and easy to experiment with.
Cheers,
Charles.
That’s a nice solution. ClickEvent has a method isDoubleClick(). I did not know about that.
Possible downside : it’s a server hop; depending on context, that may or may not be an issue.