gwtproject / gwt

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

Feature Request: make RichTextBox and TextArea support Auto-Resizing #7011

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 7012

For TextArea,it not difficult and I have implemented it.But for
RichTextArea,It is not so easy(for me).Hope this feature can be
supported by GWT originally.

Reported by Alexander.Luya on 2011-11-22 03:49:25

dankurka commented 9 years ago

Reported by clayberg@google.com on 2011-11-23 14:31:10

dankurka commented 9 years ago
Alexander, you mentioned having patched TextArea for this, can you attach an example
of your implementation? And what do you mean by auto-resizing? Based on the size of
the text box's content, or the size of the browser window?

Reported by stephen.haberman on 2011-11-24 03:41:18

dankurka commented 9 years ago
For TextArea,I just followed this blog:http://ambitz.com/2010/12/11/autogrow-textarea-with-gwt/,and
I hope RichTextBox can support auto-resizing(auto-growing and auto-shrinking),but it
is not so easy for me to implement it.

Reported by Alexander.Luya on 2011-11-25 06:06:57

dankurka commented 9 years ago
Below code can make RichTextArea auto-grow-or-shrink vertically based on KeyUp event,and
question is how to do same thing when user paste or cut content in or out(Google plus
has implemented this).MouseUp and CONTEXTMENU events have been tried,got no luck.Can
anybody give a solution?Thanks.

public AutoResizeTextArea()
{
    new Timer()
    {
        @Override
        public void run()
        {
            (doc = ((FrameElement) getElement().cast()).getContentDocument()).getBody()
                    .setAttribute("style", "word-wrap:break-word;overflow:hidden;");
        }
    }.schedule(100);
}

@Override
public void onBrowserEvent(Event event)
{
    switch (DOM.eventGetType(event))
    {
        case Event.ONKEYUP:
            adjustHeight();
            break;
    }
}

private void adjustHeight()
{
    if (doc.getDocumentElement()
            .getOffsetHeight() != doc.getClientHeight())
    {
        setHeight((doc.getDocumentElement()
                .getOffsetHeight() + 19) + "px");
    }
}

Reported by Alexander.Luya on 2012-04-25 14:27:51

dankurka commented 9 years ago

Reported by dankurka@google.com on 2013-05-28 01:46:09