SmartGWT RichTextEditor not capturing any onBrowserEvents
Asked Answered
D

1

7

I'm using SmartGWT on my application and have encountered some issues when trying to get events from the browser. I need to get the ONPASTE event, but when I try to use it, the method onBrowserEvent never even gets called.

Here is the code that I'm using.

import com.google.gwt.user.client.Event;
import com.smartgwt.client.widgets.RichTextEditor;

public class CustomRichTextEditor extends RichTextEditor {
    public CustomRichTextEditor() {
        super();
        sinkEvents(Event.ONPASTE);
    }

    @Override
    public void onBrowserEvent(Event event) {
        super.onBrowserEvent(event);
        System.out.println("Event.getTypeInt: " + event.getTypeInt() + " - Event.getType: " + event.getType());
        switch (event.getTypeInt()) {
        case Event.ONPASTE:
            System.out.println("Paste Detected");
            break;
        }
    }

}

Can anybody help me?

Danettedaney answered 27/11, 2015 at 22:59 Comment(0)
M
5

RichTextEditor actualy do not attach to any input elements. And use textarea element like a container for transport only. It doenst subscribe to events like ONPASTE at all.

This question was first asked in gwt google group. And nice guy Brandon Donnelson found why this do not work and how to solve it.

Here is working gwt example with custom RichTextEditor (about ~300 lines of code in 5 classes and do not think that paste it here is good idea) which add event bindind to RichTextEditor and allow to ONPASTE and some other events work. It works as follow:

enter image description here

p.s. Also keep in mind, this RichTextEditor strange behaviour was submited as bug in november 2011. But still not fixed in original code.

Michelinamicheline answered 16/12, 2015 at 8:9 Comment(1)
Thanks a lot for the answer @misterion , will try to do that here.Danettedaney

© 2022 - 2024 — McMap. All rights reserved.