]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #5144
authorJohn Alhroos <john.ahlroos@itmill.com>
Wed, 16 Jun 2010 13:39:36 +0000 (13:39 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Wed, 16 Jun 2010 13:39:36 +0000 (13:39 +0000)
svn changeset:13713/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

index e8cf37c1ffc5a0d4f8d932d8eb2130416a16a62f..9a9aaab587c931b3d3a6f89bf677f7917305d459 100644 (file)
@@ -274,6 +274,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
     private String height;
     private String width = "";
     private boolean rendering = false;
+    private boolean hasFocus = false;
     private int dragmode;
 
     private int multiselectmode;
@@ -355,12 +356,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      */
     private void fireColumnResizeEvent(String columnId, int originalWidth,
             int newWidth) {
-            client.updateVariable(paintableId, "columnResizeEventColumn",
-                    columnId, false);
-            client.updateVariable(paintableId, "columnResizeEventPrev",
-                    originalWidth, false);
-            client.updateVariable(paintableId, "columnResizeEventCurr",
-                    newWidth, immediate);
+        client.updateVariable(paintableId, "columnResizeEventColumn", columnId,
+                false);
+        client.updateVariable(paintableId, "columnResizeEventPrev",
+                originalWidth, false);
+        client.updateVariable(paintableId, "columnResizeEventCurr", newWidth,
+                immediate);
 
     }
 
@@ -671,7 +672,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
         showRowHeaders = uidl.getBooleanAttribute("rowheaders");
         showColHeaders = uidl.getBooleanAttribute("colheaders");
-        
+
         nullSelectionAllowed = uidl.hasAttribute("nsa") ? uidl
                 .getBooleanAttribute("nsa") : true;
 
@@ -4807,15 +4808,16 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             scrollBodyPanel.setHorizontalScrollPosition(scrollBodyPanel
                     .getHorizontalScrollPosition()
                     + scrollingVelocity);
+            return true;
         }
 
         // Select navigation
         if (selectMode > SELECT_MODE_NONE
                 && keycode == getNavigationSelectKey()) {
             if (selectMode == SELECT_MODE_SINGLE) {
-                boolean wasSelected = focusedRow.isSelected();                                
-                deselectAll();                
-                if (!wasSelected || !nullSelectionAllowed ) {
+                boolean wasSelected = focusedRow.isSelected();
+                deselectAll();
+                if (!wasSelected || !nullSelectionAllowed) {
                     focusedRow.toggleSelection(true);
                 }
 
@@ -4918,21 +4920,23 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      * .gwt.event.dom.client.KeyPressEvent)
      */
     public void onKeyPress(KeyPressEvent event) {
-        if (handleNavigation(event.getNativeEvent().getKeyCode(), event
-                .isControlKeyDown()
-                || event.isMetaKeyDown(), event.isShiftKeyDown())) {
-            event.preventDefault();
-        }
-
-        // Start the velocityTimer
-        if (scrollingVelocityTimer == null) {
-            scrollingVelocityTimer = new Timer() {
-                @Override
-                public void run() {
-                    scrollingVelocity++;
-                }
-            };
-            scrollingVelocityTimer.scheduleRepeating(100);
+        if (hasFocus) {
+            if (handleNavigation(event.getNativeEvent().getKeyCode(), event
+                    .isControlKeyDown()
+                    || event.isMetaKeyDown(), event.isShiftKeyDown())) {
+                event.preventDefault();
+            }
+
+            // Start the velocityTimer
+            if (scrollingVelocityTimer == null) {
+                scrollingVelocityTimer = new Timer() {
+                    @Override
+                    public void run() {
+                        scrollingVelocity++;
+                    }
+                };
+                scrollingVelocityTimer.scheduleRepeating(100);
+            }
         }
     }
 
@@ -4944,21 +4948,23 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      * .event.dom.client.KeyDownEvent)
      */
     public void onKeyDown(KeyDownEvent event) {
-        if (handleNavigation(event.getNativeEvent().getKeyCode(), event
-                .isControlKeyDown()
-                || event.isMetaKeyDown(), event.isShiftKeyDown())) {
-            event.preventDefault();
-        }
-
-        // Start the velocityTimer
-        if (scrollingVelocityTimer == null) {
-            scrollingVelocityTimer = new Timer() {
-                @Override
-                public void run() {
-                    scrollingVelocity++;
-                }
-            };
-            scrollingVelocityTimer.scheduleRepeating(100);
+        if (hasFocus) {
+            if (handleNavigation(event.getNativeEvent().getKeyCode(), event
+                    .isControlKeyDown()
+                    || event.isMetaKeyDown(), event.isShiftKeyDown())) {
+                event.preventDefault();
+            }
+
+            // Start the velocityTimer
+            if (scrollingVelocityTimer == null) {
+                scrollingVelocityTimer = new Timer() {
+                    @Override
+                    public void run() {
+                        scrollingVelocity++;
+                    }
+                };
+                scrollingVelocityTimer.scheduleRepeating(100);
+            }
         }
     }
 
@@ -4972,6 +4978,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
     public void onFocus(FocusEvent event) {
         if (isFocusable()) {
             scrollBodyPanel.addStyleName("focused");
+            hasFocus = true;
 
             // Focus a row if no row is in focus
             if (focusedRow == null) {
@@ -4989,6 +4996,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      */
     public void onBlur(BlurEvent event) {
         scrollBodyPanel.removeStyleName("focused");
+        hasFocus = false;
 
         // Unfocus any row
         setRowFocus(null);