From 7edff2dad305481601cdd6c876d24fd7a4f3f9a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Wed, 25 Jul 2012 11:08:36 +0000 Subject: [PATCH] Make a read-only RichTextArea scrollable (#7036) svn changeset:24024/svn branch:6.8 --- .../VAADIN/themes/base/textfield/richtext.css | 9 ++++++++- .../gwt/client/ui/richtextarea/VRichTextArea.java | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/WebContent/VAADIN/themes/base/textfield/richtext.css b/WebContent/VAADIN/themes/base/textfield/richtext.css index a304fa2a57..98726756f5 100644 --- a/WebContent/VAADIN/themes/base/textfield/richtext.css +++ b/WebContent/VAADIN/themes/base/textfield/richtext.css @@ -1,12 +1,19 @@ .v-richtextarea { border: 1px solid #aaa; - overflow: hidden; } .v-richtextarea .gwt-RichTextArea { background: #fff; border: none; } +/* IE6 needs a hack to render the editor with a correct height */ +.v-ie6 .v-richtextarea { + overflow: hidden; +} +.v-ie6 .v-scrollable { + overflow: auto; +} + .v-richtextarea .gwt-RichTextToolbar { white-space: nowrap; background: #959595 url(img/richtext-toolbar-bg.png) repeat-x 0 -42px; diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java index bf0a423474..54a8ff6ad6 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java +++ b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java @@ -34,6 +34,8 @@ import com.vaadin.terminal.gwt.client.ui.Field; import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; +import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate; +import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate.TouchScrollHandler; /** * This class implements a basic client side rich text editor component. @@ -81,6 +83,8 @@ public class VRichTextArea extends Composite implements Paintable, Field, private boolean readOnly = false; + private TouchScrollHandler touchScrollHandler = null; + public VRichTextArea() { createRTAComponents(); fp.add(formatter); @@ -88,7 +92,6 @@ public class VRichTextArea extends Composite implements Paintable, Field, initWidget(fp); setStyleName(CLASSNAME); - } private void createRTAComponents() { @@ -120,10 +123,18 @@ public class VRichTextArea extends Composite implements Paintable, Field, } rta.setHTML(currentValue); fp.add(rta); + if (touchScrollHandler != null) { + touchScrollHandler.removeElement(fp.getElement()); + } } else { html.setHTML(currentValue); fp.remove(rta); fp.add(html); + if (touchScrollHandler == null) { + touchScrollHandler = TouchScrollDelegate + .enableTouchScrolling(this); + } + touchScrollHandler.addElement(fp.getElement()); } } -- 2.39.5