Hi Thanks for your response,
on both front at GWT and Javascript I am at beginners level, will it be
possible to have modification in below function, which will
support copyclipboard functionality with Microsoft Edge. I tried
navigator.clipboard.writeText() but code is not getting compiled.
public static native String getClipboardData()/*-{
i*f($wnd.clipboardData && clipboardData.setData){*
*return $wnd.clipboardData.getData('Text');*
}
On Thu, Oct 20, 2022 at 12:36 PM Vassilis Virvilis <[email protected]>
wrote:
> For non IE browsers I have this:
>
> // attach event listeners
> // copy - cut - paste handlers
> ((Element) Js.cast(getElement())).addEventListener("copy",
> copy_li);
> ((Element) Js.cast(getElement())).addEventListener("cut",
> cut_li);
> ((Element) Js.cast(getElement())).addEventListener("paste",
> paste_li);
>
> where (Element) is elemental2.dom.Element
>
> copy_li is something like this:
>
> final elemental2.dom.EventListener copy_li = new
> elemental2.dom.EventListener() {
> @Override
> public void handleEvent(elemental2.dom.Event evt) {
> final ClipboardEvent event = Js.cast(evt);
> copy(event);
> }
> };
>
> where ClipboardEvent is elemental2.dom.ClipboardEvent
>
> I need a copy function because I reuse it in the "Cut" functionality also.
>
> and finally copy is something like this
>
> private void copy(ClipboardEvent event) {
> if (!hasData()) { // <-- hasData() is your application specific
> function
> return;
> }
>
> // do application stuff get/iterate and finally get the data in a
> String form somehow...
> final String data = getData(); // application specific
>
> event.clipboardData.setData("text/plain", data);
> event.preventDefault();
> }
>
> Similarly the paste evenListener:
>
> final elemental2.dom.EventListener paste_li = new
> elemental2.dom.EventListener() {
> @Override
> public void handleEvent(elemental2.dom.Event evt) {
> final ClipboardEvent event = Js.cast(evt);
> final String data =
> event.clipboardData.getData("text/plain")
> event.preventDefault();
> if (data == null)
> return;
>
> // now you need somehow to propagate data to the
> interesting parties (methods, classes etc)
> // I am using the EventBus from GWT
> getEventBus().fireEvent(new PasteEvent(data));
> }
> };
>
> Hope that helps
>
> Vassilis
>
> On Thu, Oct 20, 2022 at 9:18 AM Pramod Patil <[email protected]>
> wrote:
>
>> Hi All,
>> In our GWT application we are using Java native method call for
>> Copytoclipboard functionality. Please refer below code
>>
>> public static native String getClipboardData()/*-{
>> if($wnd.clipboardData && clipboardData.setData){
>> return $wnd.clipboardData.getData('Text');
>> }
>> }
>> }-*/
>> public static native String setClipboardData(String data)/*-{
>> if($wnd.clipboardData && clipboardData.setData){
>> return $wnd.clipboardData.setData('Text',Data);
>> }
>> }
>> }-*/
>>
>> So above code is working fine with IE browser but not working with modern
>> browser. I know this is not GWT specific question, but I don't have much
>> knowledge with Javascript, so anyone who knows Javascript, please help here.
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "GWT Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com
>> <https://groups.google.com/d/msgid/google-web-toolkit/c7ebae01-b41f-440a-b4da-b6c1c91231e3n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Vassilis Virvilis
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEybr2Kr5hEZ12tKccfMMuR6QZGazTZuZqRHVMd0bKg3ZA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
Thanks and regards,
Pramod Patil
Contact +91-8975432800
--
You received this message because you are subscribed to the Google Groups "GWT
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-web-toolkit/CAAXS9-UatQ84dXiZeD7Q0TSXA9HT56UGZQLCzvZ4fFqbEoF23A%40mail.gmail.com.