From 708662f34f991636c5bf62c15c3528a1ad08cf63 Mon Sep 17 00:00:00 2001 From: John Alhroos Date: Wed, 16 Jun 2010 13:39:36 +0000 Subject: [PATCH] Fix for #5144 svn changeset:13713/svn branch:6.4 --- .../terminal/gwt/client/ui/VScrollTable.java | 88 ++++++++++--------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index e8cf37c1ff..9a9aaab587 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -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); -- 2.39.5