gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 376 forks source link

Can't set style and register cut/paste method to RichTextArea? #7603

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 7606

Following code is used to set attribute style to body element  and register cut/paste
code to it,but failed.Strangelly,when debugging,variable body is not null and  attribute
"style" exists,but frame hasn't this child.Running work doesn't work as expected,and
NPE got thrown out when call setBodyContent()

public class TextAreaExt extends RichTextArea
{
    private BodyElement body;

    @Override
    protected void onLoad()
    {
        super.onLoad();
        body = ((FrameElement) getElement().cast())
                    .getContentDocument().getBody();
        body.setAttribute("style", "color:gray;");
        registerOnCut(body);
    }

    public void setBodyContent(String text)
    {
        body.setInnerText(text);
    }

    private native void registerOnCut(BodyElement element) /*-{
        var that = this;
        console.log("registerOnCut");
        element.oncut = $entry(function(event) {
            //invoke method to adjust height based on content
            return false;
        });
        element.onpaste = $entry(function(event) {
            //invoke method to adjust height based on content
            return false;
        });
    }-*/;
}

Reported by Alexander.Luya on 2012-08-20 00:52:16

dankurka commented 9 years ago
It's my fault,and this works can be done it Initialize handler

Reported by Alexander.Luya on 2012-10-14 11:39:02

dankurka commented 9 years ago

Reported by t.broyer on 2012-10-14 13:40:16