]> source.dussan.org Git - vaadin-framework.git/commitdiff
#6845 Fixed problem with earlier fix and cleaned up code
authorArtur Signell <artur.signell@itmill.com>
Fri, 29 Jul 2011 06:39:53 +0000 (06:39 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 29 Jul 2011 06:39:53 +0000 (06:39 +0000)
svn changeset:20012/svn branch:6.6

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

index cf7e8b5a70bb6d2703a06f6580c1ce0271ee069c..a8974aa5bcf4723b711e979b3fb6bc359cdeb08c 100644 (file)
@@ -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) {