Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

onpaste event support in TextItem (and others...)

$
0
0
Hi,

We would like to know if the onpaste event will be added in the future seeing that all modern browsers support in this event some capacity (even if it is only to cancel the even...)

What code would be required if we were to implement this ourselves?
I would hazard to guess that we would need at least the following:

- HasPasteHandler inteface
- PasteEvent class
- PasteHandler interface

...as well as something similar to this code (from FormItem.java)
Code:

    public HandlerRegistration addKeyDownHandler(com.smartgwt.client.widgets.form.fields.events.KeyDownHandler handler) {
        if(getHandlerCount(com.smartgwt.client.widgets.form.fields.events.KeyDownEvent.getType()) == 0) setupKeyDownEvent();
        return doAddHandler(handler, com.smartgwt.client.widgets.form.fields.events.KeyDownEvent.getType());
    }

    private native void setupKeyDownEvent() /*-{
        var obj = null;
        obj = this.@com.smartgwt.client.core.DataClass::getJsObj()();
        var selfJ = this;
        var keyDown = $debox($entry(function(param){
            var event = @com.smartgwt.client.widgets.form.fields.events.KeyDownEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param);
            selfJ.@com.smartgwt.client.core.DataClass::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event);
                var ret = event.@com.smartgwt.client.event.Cancellable::isCancelled()();
                return !ret;
            }));
        obj.keyDown =
            function () {
                var param = {"item" : arguments[0], "form" : arguments[1], "keyName" : arguments[2]};
                return keyDown(param) == true;
            }
        ;
  }-*/;

Would this be sufficient? I'm sure that I'm being a little naive and am surely missing something here...
Is this the right way of implementing this or am I completely off track?

Thanks,

Frederic

Viewing all articles
Browse latest Browse all 4756

Trending Articles