I am trying to implement the cut, copy and paste functionality for a
page that has around 70 widgets including text boxes, list boxes,
labels, containers, panels and so on. The cut, copy and paste buttons
are part of these. When a User selects text in some text box in the
page and clicks on copy, the text box loses focus and the copy button
now has it. I need the text to call a method that has some Javascript
call in it like:
$wnd.window.clipboardData.setData(“Text”,text);
In order for me to do that I need text from the text box and because
the copy button now has it, I do not know where it has been selected
from.
Can anyone let me know if they have done anything similar before using
GWT?
A little late but finally I am posting how i worked around this issue last year itself.
I created MouseOverHandlers for the cut, copy and paste buttons and when the User hovers over any of those widgets, in the handling logic I am using some native javaScript code to find the active element in DOM and am converting it to a GWT element using GQuery.
After converting it, I check if it is an instance of TextBoxBase and if it is, I just pick up the text from that field to cut, copy. Paste works similarly except I paste only when the widget is an instance of TextBoxBase (so that TextBox and TextArea widgets are covered.)