]> source.dussan.org Git - vaadin-framework.git/commitdiff
forgotten changes for #1834
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 10 Jul 2008 05:17:40 +0000 (05:17 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 10 Jul 2008 05:17:40 +0000 (05:17 +0000)
svn changeset:5075/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java

index 925a5c3758056db104670dd20af93bfd77a5a5cd..8a408597c3fece3b81cef5389db7f384abbaa371 100644 (file)
@@ -50,6 +50,10 @@ public class IPanel extends SimplePanel implements Paintable,
 
     private Element geckoCaptionMeter;
 
+    private int scrollTop;
+
+    private int scrollLeft;
+
     public IPanel() {
         super();
         DOM.appendChild(getElement(), captionNode);
@@ -66,6 +70,7 @@ public class IPanel extends SimplePanel implements Paintable,
         DOM.setElementProperty(bottomDecoration, "className", CLASSNAME
                 + "-deco");
         DOM.sinkEvents(getElement(), Event.ONKEYDOWN);
+        DOM.sinkEvents(contentNode, Event.ONSCROLL);
     }
 
     protected Element getContainerElement() {
@@ -169,6 +174,18 @@ public class IPanel extends SimplePanel implements Paintable,
             }
         }
 
+        if (uidl.hasVariable("scrollTop")
+                && uidl.getIntVariable("scrollTop") != scrollTop) {
+            scrollTop = uidl.getIntVariable("scrollTop");
+            DOM.setElementPropertyInt(contentNode, "scrollTop", scrollTop);
+        }
+
+        if (uidl.hasVariable("scrollLeft")
+                && uidl.getIntVariable("scrollLeft") != scrollLeft) {
+            scrollLeft = uidl.getIntVariable("scrollLeft");
+            DOM.setElementPropertyInt(contentNode, "scrollLeft", scrollLeft);
+        }
+
     }
 
     private void handleError(UIDL uidl) {
@@ -310,7 +327,20 @@ public class IPanel extends SimplePanel implements Paintable,
             shortcutHandler.handleKeyboardEvent(event);
             return;
         }
-        if (errorIndicatorElement != null
+        if (type == Event.ONSCROLL) {
+            int newscrollTop = DOM.getElementPropertyInt(contentNode,
+                    "scrollTop");
+            int newscrollLeft = DOM.getElementPropertyInt(contentNode,
+                    "scrollLeft");
+            if (client != null
+                    && (newscrollLeft != scrollLeft || newscrollTop != scrollTop)) {
+                ApplicationConnection.getConsole().log("scrollded panel");
+                scrollLeft = newscrollLeft;
+                scrollTop = newscrollTop;
+                client.updateVariable(id, "scrollTop", scrollTop, false);
+                client.updateVariable(id, "scrollLeft", scrollLeft, false);
+            }
+        } else if (errorIndicatorElement != null
                 && DOM.compare(target, errorIndicatorElement)) {
             switch (type) {
             case Event.ONMOUSEOVER: