Mouse event

Hi,

I have been working with the toolkit for a month and it is going well.
I would like to know how to handle mouse event on plain text with the toolkit. For example, if I highlight part of the text of a Label, then right-click to perform some action, how to set up this?

Sylvain

[quote=Sylvain]
Hi,

I have been working with the toolkit for a month and it is going well.
I would like to know how to handle mouse event on plain text with the toolkit. For example, if I highlight part of the text of a Label, then right-click to perform some action, how to set up this?

Sylvain
[/quote]Hi,

Getting the current selection requires somewhat deep client-side code. The problem is that GWT does not support finding the current selection, nor is it available from the lower-level DOM API of GWT, so you probably need to get it with JavaScript, with window.getSelection(). See
http://developer.mozilla.org/en/docs/DOM:Selection
. There may be differences between browsers.

See
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JavaScriptNativeInterface.html
for details on the JSNI for embedding JavaScript in GWT code. The GWT source code also provides a lot of examples for using JavaScript in GWT. I suppose you could find the selection also otherwise, without JSNI, if you include the JS in some other way in the browser, although communicating the selection to the server-side may prove difficult that way.

You can use Actions in Toolkit to open a context menu with right-mouse-click, as is done in Tree and Table. See for example TreeDemo.java. I hope it is suitable in your case as well.

Thanks a lot for the answer. It should be fine.

Sylvain