changeset 202:466cddfdb54c

RT-18706: TreeView, ListView, TableView: second right mouse click starts editing
author jgiles
date Thu, 29 Dec 2011 15:50:42 +1000
parents 2863f843dc18
children 8251a20df5da
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, 33 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java	Thu Dec 29 10:23:52 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java	Thu Dec 29 15:50:42 2011 +1000
@@ -175,14 +175,16 @@
 
         lv.getSelectionModel().clearAndSelect(index);
 
-        // handle editing
-        if (e.getClickCount() == 1 && isAlreadySelected) {
-            lv.edit(index);
-        } else if (e.getClickCount() == 1) {
-            // cancel editing
-            lv.edit(-1);
-        } else if (e.getClickCount() == 2 && getControl().isEditable()) {
-            lv.edit(index);
+        // handle editing, which only occurs with the primary mouse button
+        if (e.isPrimaryButtonDown()) {
+            if (e.getClickCount() == 1 && isAlreadySelected) {
+                lv.edit(index);
+            } else if (e.getClickCount() == 1) {
+                // cancel editing
+                lv.edit(-1);
+            } else if (e.getClickCount() == 2 && getControl().isEditable()) {
+                lv.edit(index);
+            }
         }
     }
 }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java	Thu Dec 29 10:23:52 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java	Thu Dec 29 15:50:42 2011 +1000
@@ -179,14 +179,17 @@
 
         tv.getSelectionModel().clearAndSelect(row, getControl().getTableColumn());
 
-        if (e.getClickCount() == 1 && isAlreadySelected) {
-            tv.edit(row, getControl().getTableColumn());
-        } else if (e.getClickCount() == 1) {
-            // cancel editing
-            tv.edit(-1, null);
-        } else if (e.getClickCount() == 2 && getControl().isEditable()) {
-            // edit at the specified row and column
-            tv.edit(row, getControl().getTableColumn());
+        // handle editing, which only occurs with the primary mouse button
+        if (e.isPrimaryButtonDown()) {
+            if (e.getClickCount() == 1 && isAlreadySelected) {
+                tv.edit(row, getControl().getTableColumn());
+            } else if (e.getClickCount() == 1) {
+                // cancel editing
+                tv.edit(-1, null);
+            } else if (e.getClickCount() == 2 && getControl().isEditable()) {
+                // edit at the specified row and column
+                tv.edit(row, getControl().getTableColumn());
+            }
         }
     }
 
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java	Thu Dec 29 10:23:52 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java	Thu Dec 29 15:50:42 2011 +1000
@@ -170,7 +170,7 @@
         }
     }
 
-    private void simpleSelect(MouseEvent event) {
+    private void simpleSelect(MouseEvent e) {
         TreeView tv = getControl().getTreeView();
         int index = getControl().getIndex();
         MultipleSelectionModel sm = tv.getSelectionModel();
@@ -178,15 +178,17 @@
 
         tv.getSelectionModel().clearAndSelect(index);
 
-        // handle editing
-        if (event.getClickCount() == 1 && isAlreadySelected) {
-            tv.edit(getControl().getTreeItem());
-        } else if (event.getClickCount() == 1) {
-            // cancel editing
-            tv.edit(null);
-        } else if (event.getClickCount() == 2 && getControl().isEditable()) {
-            // try to expand/collapse tree item
-            getControl().getTreeItem().setExpanded(! getControl().getTreeItem().isExpanded());
+        // handle editing, which only occurs with the primary mouse button
+        if (e.isPrimaryButtonDown()) {
+            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()) {
+                // try to expand/collapse tree item
+                getControl().getTreeItem().setExpanded(! getControl().getTreeItem().isExpanded());
+            }
         }
     }
 }