From c2b5723c72cf692811e3e95257194f3b7950da87 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Wed, 6 Apr 2011 10:46:32 +0000 Subject: Fixed #6731 - tree no longer scrolls when an item is selected. svn changeset:18127/svn branch:6.5 --- src/com/vaadin/terminal/gwt/client/ui/VTree.java | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTree.java b/src/com/vaadin/terminal/gwt/client/ui/VTree.java index ddc5c174ca..a007f27136 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTree.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTree.java @@ -628,15 +628,14 @@ public class VTree extends SimpleFocusablePanel implements Paintable, * Also ensure that the Tree itself is also gains focus (TreeNodes * focus is kind of faked). */ - if (BrowserInfo.get().isOpera()) { - /* - * focusing the tree in Opera would scroll long trees up on - * clicks - */ - getElement().focus(); - } else if (!BrowserInfo.get().isIE()) { - focus(); - } // else if IE: NOP, IE will give the focus to Tree anyways + // if (BrowserInfo.get().isOpera()) { + /* + * focusing the tree in Opera would scroll long trees up on clicks + */ + // getElement().focus(); + // } else if (!BrowserInfo.get().isIE()) { + // focus(); + // } // else if IE: NOP, IE will give the focus to Tree anyways ScheduledCommand command = new ScheduledCommand() { public void execute() { @@ -787,7 +786,12 @@ public class VTree extends SimpleFocusablePanel implements Paintable, * previously modified field may contain dirty variables. */ if (!treeHasFocus) { - focus(); + if (focusedNode == null) { + getNodeByKey(key).setFocused(true); + } else { + focusedNode.setFocused(true); + } + // focus(); } final MouseEventDetails details = new MouseEventDetails(evt); ScheduledCommand command = new ScheduledCommand() { @@ -832,15 +836,15 @@ public class VTree extends SimpleFocusablePanel implements Paintable, DOM.appendChild(getElement(), ie6compatnode); DOM.sinkEvents(ie6compatnode, Event.ONCLICK); - } else if (BrowserInfo.get().isOpera()) { - /* - * We need to focus the TreeNode itself to get keyboard - * navigation to work in opera at some level. Actually focusing - * individual TreeNodes would most likely be better option for - * all browsers, I don't dare to to this at bugfix release. MT. - */ - getElement().setTabIndex(-1); - } + } // else if (BrowserInfo.get().isOpera()) { + /* + * We need to focus the TreeNode itself to get keyboard navigation + * to work in opera at some level. Actually focusing individual + * TreeNodes would most likely be better option for all browsers, I + * don't dare to to this at bugfix release. MT. + */ + getElement().setTabIndex(-1); + // } nodeCaptionDiv = DOM.createDiv(); DOM.setElementProperty(nodeCaptionDiv, "className", CLASSNAME @@ -1142,12 +1146,15 @@ public class VTree extends SimpleFocusablePanel implements Paintable, ie6compatnode.addClassName(CLASSNAME_FOCUSED); } this.focused = focused; + getElement().focus(); + treeHasFocus = true; } else if (this.focused && !focused) { nodeCaptionDiv.removeClassName(CLASSNAME_FOCUSED); if (BrowserInfo.get().isIE6()) { ie6compatnode.removeClassName(CLASSNAME_FOCUSED); } this.focused = focused; + treeHasFocus = false; } } -- cgit v1.2.3