changeset 1124:e6bbd16b510b

RT-20693: TreeCell eats double click
author jgiles
date Wed, 23 May 2012 13:12:35 +1200
parents 5461f36ebaf1
children 3eb36e8caed4
files javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java
diffstat 3 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java	Wed May 23 12:32:25 2012 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java	Wed May 23 13:12:35 2012 +1200
@@ -35,6 +35,7 @@
 import javafx.scene.control.ListView;
 import javafx.scene.control.MultipleSelectionModel;
 import javafx.scene.control.SelectionMode;
+import javafx.scene.input.MouseButton;
 import javafx.scene.input.MouseEvent;
 
 /**
@@ -160,7 +161,8 @@
             map.remove(listView);
         }
         
-        if (e.isPrimaryButtonDown() || (e.isSecondaryButtonDown() && !selected)) { 
+        MouseButton button = e.getButton();
+        if (button == MouseButton.PRIMARY || (button == MouseButton.SECONDARY && !selected)) { 
             if (sm.getSelectionMode() == SelectionMode.SINGLE) {
                 simpleSelect(e);
             } else {
@@ -204,7 +206,7 @@
         lv.getSelectionModel().clearAndSelect(index);
 
         // handle editing, which only occurs with the primary mouse button
-        if (e.isPrimaryButtonDown()) {
+        if (e.getButton() == MouseButton.PRIMARY) {
             if (e.getClickCount() == 1 && isAlreadySelected) {
                 lv.edit(index);
             } else if (e.getClickCount() == 1) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java	Wed May 23 12:32:25 2012 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java	Wed May 23 13:12:35 2012 +1200
@@ -30,6 +30,7 @@
 
 import javafx.scene.control.*;
 import javafx.scene.control.TableView.TableViewFocusModel;
+import javafx.scene.input.MouseButton;
 import javafx.scene.input.MouseEvent;
 
 /**
@@ -189,7 +190,8 @@
 
         // we must update the table appropriately, and this is determined by
         // what modifiers the user held down as they released the mouse.
-        if (e.isPrimaryButtonDown() || (e.isSecondaryButtonDown() && !selected)) { 
+        MouseButton button = e.getButton();
+        if (button == MouseButton.PRIMARY || (button == MouseButton.SECONDARY && !selected)) { 
             if (sm.getSelectionMode() == SelectionMode.SINGLE) {
                 simpleSelect(e);
             } else {
@@ -245,7 +247,7 @@
         tv.getSelectionModel().clearAndSelect(row, getControl().getTableColumn());
 
         // handle editing, which only occurs with the primary mouse button
-        if (e.isPrimaryButtonDown()) {
+        if (e.getButton() == MouseButton.PRIMARY) {
             if (e.getClickCount() == 1 && isAlreadySelected) {
                 tv.edit(row, getControl().getTableColumn());
             } else if (e.getClickCount() == 1) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java	Wed May 23 12:32:25 2012 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java	Wed May 23 13:12:35 2012 +1200
@@ -32,6 +32,7 @@
 
 import javafx.scene.Node;
 import javafx.scene.control.*;
+import javafx.scene.input.MouseButton;
 import javafx.scene.input.MouseEvent;
 
 /**
@@ -202,8 +203,9 @@
         } else {
             map.remove(treeView);
         }
-
-        if (event.isPrimaryButtonDown() || (event.isSecondaryButtonDown() && !selected)) { 
+        
+        MouseButton button = event.getButton();
+        if (button == MouseButton.PRIMARY || (button == MouseButton.SECONDARY && !selected)) { 
             if (sm.getSelectionMode() == SelectionMode.SINGLE) {
                 simpleSelect(event);
             } else {
@@ -246,13 +248,13 @@
         tv.getSelectionModel().clearAndSelect(index);
 
         // handle editing, which only occurs with the primary mouse button
-        if (e.isPrimaryButtonDown()) {
+        if (e.getButton() == MouseButton.PRIMARY) {
             if (e.getClickCount() == 1 && isAlreadySelected) {
                 tv.edit(getControl().getTreeItem());
             } else if (e.getClickCount() == 1) {
                 // cancel editing
                 tv.edit(null);
-            } else if (e.getClickCount() == 2 && getControl().isEditable()) {
+            } else if (e.getClickCount() == 2 && ! getControl().isEditable()) {
                 // try to expand/collapse tree item
                 getControl().getTreeItem().setExpanded(! getControl().getTreeItem().isExpanded());
             }