From a9db3f9aeb587ba8c2296193571cea33f8f9c155 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 29 Jul 2011 06:39:53 +0000 Subject: [PATCH] #6845 Fixed problem with earlier fix and cleaned up code svn changeset:20012/svn branch:6.6 --- .../vaadin/terminal/gwt/client/ui/VTree.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTree.java b/src/com/vaadin/terminal/gwt/client/ui/VTree.java index cf7e8b5a70..a8974aa5bc 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTree.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTree.java @@ -869,24 +869,30 @@ public class VTree extends FocusElementPanel implements Paintable, final MouseEventDetails details = new MouseEventDetails(evt); ScheduledCommand command = new ScheduledCommand() { public void execute() { - if (details.getButton() == 0) { - // non-immediate iff an immediate select event is going - // to - // happen and the left button was clicked - boolean imm = !immediate - || !selectable - || (!isNullSelectionAllowed && isSelected() && selectedIds - .size() == 1); - client.updateVariable(paintableId, "clickedKey", key, - false); - client.updateVariable(paintableId, "clickEvent", - details.toString(), imm); - } else { - client.updateVariable(paintableId, "clickedKey", key, - false); - client.updateVariable(paintableId, "clickEvent", - details.toString(), immediate); + // Determine if we should send the event immediately to the + // server. We do not want to send the event if there is a + // selection event happening after this. In all other cases + // we want to send it immediately. + boolean sendClickEventNow = true; + + if (details.getButton() == NativeEvent.BUTTON_LEFT + && immediate && selectable) { + // Probably a selection that will cause a value change + // event to be sent + sendClickEventNow = false; + + // The exception is that user clicked on the + // currently selected row and null selection is not + // allowed == no selection event + if (isSelected() && selectedIds.size() == 1 + && !isNullSelectionAllowed) { + sendClickEventNow = true; + } } + + client.updateVariable(paintableId, "clickedKey", key, false); + client.updateVariable(paintableId, "clickEvent", + details.toString(), sendClickEventNow); } }; if (treeHasFocus) { -- 2.39.5