diff --git a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ListCellBehavior.java @@ -139,35 +139,37 @@ map.remove(listView); } - if (sm.getSelectionMode() == SelectionMode.SINGLE) { - simpleSelect(e); - } else { - if (e.isControlDown() || e.isMetaDown()) { - if (selected) { - // we remove this row from the current selection - sm.clearSelection(index); + if (e.isPrimaryButtonDown()) { + if (sm.getSelectionMode() == SelectionMode.SINGLE) { + simpleSelect(e); + } else { + if (e.isControlDown() || e.isMetaDown()) { + if (selected) { + // we remove this row from the current selection + sm.clearSelection(index); + fm.focus(index); + } else { + // We add this row to the current selection + sm.select(index); + } + } else if (e.isShiftDown()) { + // we add all rows between the current focus and + // this row (inclusive) to the current selection. + int focusIndex = getAnchor(listView); + + // and then determine all row and columns which must be selected + int minRow = Math.min(focusIndex, index); + int maxRow = Math.max(focusIndex, index); + + // and then perform the selection + sm.clearSelection(); + sm.selectRange(minRow, maxRow+1); + + // return selection back to the focus owner fm.focus(index); } else { - // We add this row to the current selection - sm.select(index); + simpleSelect(e); } - } else if (e.isShiftDown()) { - // we add all rows between the current focus and - // this row (inclusive) to the current selection. - int focusIndex = getAnchor(listView); - - // and then determine all row and columns which must be selected - int minRow = Math.min(focusIndex, index); - int maxRow = Math.max(focusIndex, index); - - // and then perform the selection - sm.clearSelection(); - sm.selectRange(minRow, maxRow+1); - - // return selection back to the focus owner - fm.focus(index); - } else { - simpleSelect(e); } } } diff --git a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TableCellBehavior.java @@ -131,47 +131,49 @@ // we must update the table appropriately, and this is determined by // what modifiers the user held down as they released the mouse. - if (sm.getSelectionMode() == SelectionMode.SINGLE) { - simpleSelect(e); - } else { - if (e.isControlDown() || e.isMetaDown()) { - if (selected) { - // we remove this row/cell from the current selection - sm.clearSelection(row, tableColumn); - fm.focus(row, tableColumn); + if (e.isPrimaryButtonDown()) { + if (sm.getSelectionMode() == SelectionMode.SINGLE) { + simpleSelect(e); + } else { + if (e.isControlDown() || e.isMetaDown()) { + if (selected) { + // we remove this row/cell from the current selection + sm.clearSelection(row, tableColumn); + fm.focus(row, tableColumn); + } else { + // We add this cell/row to the current selection + sm.select(row, tableColumn); + } + } else if (e.isShiftDown()) { + // we add all cells/rows between the current selection focus and + // this cell/row (inclusive) to the current selection. + TablePosition focusedCell = map.containsKey(tableView) ? map.get(tableView) : fm.getFocusedCell(); + + // and then determine all row and columns which must be selected + int minRow = Math.min(focusedCell.getRow(), row); + int maxRow = Math.max(focusedCell.getRow(), row); + int minColumn = Math.min(focusedCell.getColumn(), column); + int maxColumn = Math.max(focusedCell.getColumn(), column); + + // clear selection + sm.clearSelection(); + + // and then perform the selection + if (sm.isCellSelectionEnabled()) { + for (int _row = minRow; _row <= maxRow; _row++) { + for (int _col = minColumn; _col <= maxColumn; _col++) { + sm.select(_row, tableView.getVisibleLeafColumn(_col)); + } + } + } else { + sm.selectRange(minRow, maxRow + 1); + } + + // return selection back to the focus owner + fm.focus(new TablePosition(tableView, row, tableColumn)); } else { - // We add this cell/row to the current selection - sm.select(row, tableColumn); + simpleSelect(e); } - } else if (e.isShiftDown()) { - // we add all cells/rows between the current selection focus and - // this cell/row (inclusive) to the current selection. - TablePosition focusedCell = map.containsKey(tableView) ? map.get(tableView) : fm.getFocusedCell(); - - // and then determine all row and columns which must be selected - int minRow = Math.min(focusedCell.getRow(), row); - int maxRow = Math.max(focusedCell.getRow(), row); - int minColumn = Math.min(focusedCell.getColumn(), column); - int maxColumn = Math.max(focusedCell.getColumn(), column); - - // clear selection - sm.clearSelection(); - - // and then perform the selection - if (sm.isCellSelectionEnabled()) { - for (int _row = minRow; _row <= maxRow; _row++) { - for (int _col = minColumn; _col <= maxColumn; _col++) { - sm.select(_row, tableView.getVisibleLeafColumn(_col)); - } - } - } else { - sm.selectRange(minRow, maxRow + 1); - } - - // return selection back to the focus owner - fm.focus(new TablePosition(tableView, row, tableColumn)); - } else { - simpleSelect(e); } } } diff --git a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java @@ -143,34 +143,36 @@ map.remove(treeView); } - if (sm.getSelectionMode() == SelectionMode.SINGLE) { - simpleSelect(event); - } else { - if (event.isControlDown() || event.isMetaDown()) { - if (selected) { - // we remove this row from the current selection - sm.clearSelection(index); + if (event.isPrimaryButtonDown()) { + if (sm.getSelectionMode() == SelectionMode.SINGLE) { + simpleSelect(event); + } else { + if (event.isControlDown() || event.isMetaDown()) { + if (selected) { + // we remove this row from the current selection + sm.clearSelection(index); + fm.focus(index); + } else { + // We add this row to the current selection + sm.select(index); + } + } else if (event.isShiftDown()) { + // we add all rows between the current selection focus and + // this row (inclusive) to the current selection. + final int focusedIndex = getAnchor(treeView); + + // and then determine all row and columns which must be selected + int minRow = Math.min(focusedIndex, index); + int maxRow = Math.max(focusedIndex, index); + + // and then perform the selection + sm.clearSelection(); + sm.selectRange(minRow, maxRow+1); + fm.focus(index); } else { - // We add this row to the current selection - sm.select(index); + simpleSelect(event); } - } else if (event.isShiftDown()) { - // we add all rows between the current selection focus and - // this row (inclusive) to the current selection. - final int focusedIndex = getAnchor(treeView); - - // and then determine all row and columns which must be selected - int minRow = Math.min(focusedIndex, index); - int maxRow = Math.max(focusedIndex, index); - - // and then perform the selection - sm.clearSelection(); - sm.selectRange(minRow, maxRow+1); - - fm.focus(index); - } else { - simpleSelect(event); } } }