Read-only RichTextArea?

1,014 views
Skip to first unread message

Elchin

unread,
Dec 16, 2009, 9:28:45 AM12/16/09
to Google Web Toolkit
Is there a way to make RichTextArea read-only like TextArea.setReadOnly
(true)?
What I need in my application is the possibility to edit the rich text
only by buttons in toolbar, and not through typing.

Elchin

unread,
Jan 2, 2010, 5:56:14 PM1/2/10
to Google Web Toolkit
One way would be catching all events, and redoing them, but that is a
big time hassle, I wonder if there is any way to do it from DOM?

On Dec 16 2009, 6:28 pm, Elchin <elchin.asga...@gmail.com> wrote:
> Is there a way to makeRichTextArearead-only like TextArea.setReadOnly

vacorda

unread,
Jan 3, 2010, 12:05:38 AM1/3/10
to Google Web Toolkit
You can try something like this this:
DOM.setElementPropertyBoolean(getElement(), "disabled", <true or
false>);

Manuel Carrasco Moñino

unread,
Jan 12, 2010, 6:10:20 AM1/12/10
to google-we...@googlegroups.com
You can try setting on/off the iframe designMode attribute , something like this.

   RichTextArea area = new RichTextArea();

   setEnabled(area.getElement(), false);

   native void setEnabled(Element iframe, boolean b) /*-{
       iframe.contentWindow.document.designMode = b ? 'On' : 'Off';
    }-*/;

It works for ff and webkit, ie seems not working.

Regards
Manuel Carrasco Moñino


--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



Manuel Carrasco Moñino

unread,
Jan 12, 2010, 7:23:01 AM1/12/10
to google-we...@googlegroups.com
This method also works in IE

    private native void setEnabled(Element iframe, boolean b) /*-{
       var doc = iframe.contentWindow.document;
       if (doc.body.contentEditable)
           doc.body.contentEditable = b;
       else
           doc.designMode = b ? 'On' : 'Off';
    }-*/;

selezovikj

unread,
Jan 12, 2010, 11:13:56 AM1/12/10
to Google Web Toolkit

com.google.gwt.core.client.JavaScriptException: (TypeError):
iframe.contentWindow is null

What do you think might be causing this null pointer exception ?

On Jan 12, 1:23 pm, Manuel Carrasco Moñino <man...@apache.org> wrote:
> This method also works in IE
>
>     private native void setEnabled(Element iframe, boolean b) /*-{
>        var doc = iframe.contentWindow.document;
>        if (doc.body.contentEditable)
>            doc.body.contentEditable = b;
>        else
>            doc.designMode = b ? 'On' : 'Off';
>     }-*/;
>
> On Tue, Jan 12, 2010 at 12:10 PM, Manuel Carrasco Moñino
> <man...@apache.org>wrote:
>
>
>
> > You can try setting on/off the iframe designMode attribute , something like
> > this.
>
> >    RichTextArea area = new RichTextArea();
>
> >    setEnabled(area.getElement(), false);
>
> >    native void setEnabled(Element iframe, boolean b) /*-{
> >        iframe.contentWindow.document.designMode = b ? 'On' : 'Off';
> >     }-*/;
>
> > It works for ff and webkit, ie seems not working.
>
> > Regards
> > Manuel Carrasco Moñino
>

> > On Sun, Jan 3, 2010 at 6:05 AM, vacorda <victoraco...@gmail.com> wrote:
>
> >> You can try something like this this:
> >> DOM.setElementPropertyBoolean(getElement(), "disabled", <true or
> >> false>);
>
> >> On Jan 2, 5:56 pm, Elchin <elchin.asga...@gmail.com> wrote:
> >> > One way would be catching all events, and redoing them, but that is a
> >> > big time hassle, I wonder if there is any way to do it from DOM?
>
> >> > On Dec 16 2009, 6:28 pm, Elchin <elchin.asga...@gmail.com> wrote:
>
> >> > > Is there a way to makeRichTextArearead-only like TextArea.setReadOnly
> >> > > (true)?
> >> > > What I need in my application is the possibility to edit the rich text
> >> > > only by buttons in toolbar, and not through typing.
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "Google Web Toolkit" group.
> >> To post to this group, send email to google-we...@googlegroups.com.
> >> To unsubscribe from this group, send email to

> >> google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com>

Christian Goudreau

unread,
Feb 24, 2010, 9:59:23 AM2/24/10
to google-we...@googlegroups.com
I also came into that problem... BTW there's already a setEnabled function that should work, but doesn't... I'll check issues and report that if it's not already.

Christian

To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

Christian Goudreau

unread,
Feb 24, 2010, 10:01:55 AM2/24/10
to google-we...@googlegroups.com
Found it, as been fixed and will be released soon.


Christian
Reply all
Reply to author
Forward
0 new messages