Hi @Vassilis Virvilis, Can you please help me with how to use elemental2
api, if you can share any reference document about which dependency to add,
what should I add to <inherit names=""> etc. How to use listeners ->
((Element)
Js.cast(getElement())).addEventListener("paste", paste_li); in my case I
have a toolbox button like below code, basically a callback attached when
one clicks on it. So how to add an eventListener ? I tried to explore
myself about this but I didn't get much information. If you can share these
details it would be great help as you have already done. Thank you !!
protected Function pasteFromExcelFunction =new Function(){
public void execute(){}
}
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-VcHgEqDmhg5UQr-v%2Bj0Z15OBzyezgyCW2%2BTeJTNWK7FQ%40mail.gmail.com.