Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SmartGWT RichTextEditor not capturing any onBrowserEvents

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?

like image 463
Oliver Drummond Avatar asked Nov 27 '15 22:11

Oliver Drummond


1 Answers

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.

like image 156
Nick Bondarenko Avatar answered Oct 10 '22 18:10

Nick Bondarenko