changeset 2241:13034e263b1e

RT-27688: [TreeTableView] Support clicking to right of rightmost TreeTableCell to select a row.
author jgiles
date Tue, 15 Jan 2013 15:21:29 +1300
parents 16db5f0dcf7b
children 5801a67086d9
files javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeTableRowBehavior.java
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeTableRowBehavior.java	Tue Jan 15 14:40:33 2013 +1300
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeTableRowBehavior.java	Tue Jan 15 15:21:29 2013 +1300
@@ -26,6 +26,7 @@
 
 import javafx.scene.Node;
 import javafx.scene.control.MultipleSelectionModel;
+import javafx.scene.control.TableSelectionModel;
 import javafx.scene.control.TreeItem;
 import javafx.scene.control.TreeTableRow;
 import javafx.scene.control.TreeTableView;
@@ -61,9 +62,19 @@
         }
         
         // handle editing, which only occurs with the primary mouse button
-        if (e.getClickCount() == 2) {
-            // try to expand/collapse branch tree item
-            treeItem.setExpanded(! treeItem.isExpanded());
+        int clickCount = e.getClickCount();
+        switch (clickCount) {
+            case 1: // In the case of clicking to the right of the rightmost
+                    // TreeTableCell, we should still support selection, so that
+                    // is what we are doing here.
+                    TreeTableView table = treeTableRow.getTreeTableView();
+                    if (table == null) break;
+                    TableSelectionModel sm = table.getSelectionModel();
+                    if (sm != null) sm.select(treeItem);
+                    break;
+            case 2: // try to expand/collapse branch tree item
+                    treeItem.setExpanded(! treeItem.isExpanded());
+                    break;
         }
     }
 }