--- old/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ListCellBehavior.java 2014-02-06 14:41:48.095724500 +0100 +++ new/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ListCellBehavior.java 2014-02-06 14:41:47.883712400 +0100 @@ -25,6 +25,7 @@ package com.sun.javafx.scene.control.behavior; +import com.sun.javafx.scene.control.Logging; import javafx.scene.control.FocusModel; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; @@ -32,12 +33,12 @@ import javafx.scene.control.SelectionMode; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; +import sun.util.logging.PlatformLogger; +import sun.util.logging.PlatformLogger.Level; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.sun.javafx.scene.control.Logging; -import sun.util.logging.PlatformLogger; -import sun.util.logging.PlatformLogger.Level; /** */ @@ -84,18 +85,10 @@ * * **************************************************************************/ - // For RT-17456: have selection occur as fast as possible with mouse input. - // The idea is (consistently with some native applications we've tested) to - // do the action as soon as you can. It takes a bit more coding but provides - // the best feel: - // - when you click on a not-selected item, you can select immediately on press - // - when you click on a selected item, you need to wait whether DragDetected or Release comes first - // // To support touch devices, we have to slightly modify this behavior, such // that selection only happens on mouse release, if only minimal dragging // has occurred. private boolean latePress = false; - private boolean wasSelected = false; /*************************************************************************** @@ -119,15 +112,14 @@ @Override public void mousePressed(MouseEvent event) { boolean selectedBefore = getControl().isSelected(); - if (getControl().isSelected()) { + if (event.isSynthesized()) { latePress = true; return; - } - - doSelect(event); - - if (IS_TOUCH_SUPPORTED && selectedBefore) { - wasSelected = getControl().isSelected(); + } else { + latePress = getControl().isSelected(); + if (!latePress) { + doSelect(event); + } } } @@ -136,19 +128,10 @@ latePress = false; doSelect(event); } - - wasSelected = false; } @Override public void mouseDragged(MouseEvent event) { latePress = false; - - // the mouse has now been dragged on a touch device, we should - // remove the selection if we just added it in the last mouse press - // event - if (IS_TOUCH_SUPPORTED && ! wasSelected && getControl().isSelected()) { - getControl().getListView().getSelectionModel().clearSelection(getControl().getIndex()); - } } --- old/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ListViewBehavior.java 2014-02-06 14:41:50.725874900 +0100 +++ new/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ListViewBehavior.java 2014-02-06 14:41:50.517863000 +0100 @@ -25,6 +25,8 @@ package com.sun.javafx.scene.control.behavior; +import com.sun.javafx.PlatformUtil; +import com.sun.javafx.scene.control.skin.Utils; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.beans.value.WeakChangeListener; @@ -34,33 +36,20 @@ import javafx.event.EventType; import javafx.geometry.NodeOrientation; import javafx.geometry.Orientation; -import javafx.scene.control.*; +import javafx.scene.control.Control; +import javafx.scene.control.FocusModel; +import javafx.scene.control.ListView; +import javafx.scene.control.MultipleSelectionModel; +import javafx.scene.control.SelectionMode; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; import javafx.util.Callback; + import java.util.ArrayList; import java.util.List; -import com.sun.javafx.PlatformUtil; -import com.sun.javafx.scene.control.skin.Utils; -import static javafx.scene.input.KeyCode.A; -import static javafx.scene.input.KeyCode.BACK_SLASH; -import static javafx.scene.input.KeyCode.DOWN; -import static javafx.scene.input.KeyCode.END; -import static javafx.scene.input.KeyCode.ENTER; -import static javafx.scene.input.KeyCode.ESCAPE; -import static javafx.scene.input.KeyCode.F2; -import static javafx.scene.input.KeyCode.HOME; -import static javafx.scene.input.KeyCode.KP_DOWN; -import static javafx.scene.input.KeyCode.KP_LEFT; -import static javafx.scene.input.KeyCode.KP_RIGHT; -import static javafx.scene.input.KeyCode.KP_UP; -import static javafx.scene.input.KeyCode.LEFT; -import static javafx.scene.input.KeyCode.PAGE_DOWN; -import static javafx.scene.input.KeyCode.PAGE_UP; -import static javafx.scene.input.KeyCode.RIGHT; -import static javafx.scene.input.KeyCode.SPACE; -import static javafx.scene.input.KeyCode.UP; + +import static javafx.scene.input.KeyCode.*; /** * @@ -366,7 +355,7 @@ @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); - if (! e.isShiftDown()) { + if (! e.isShiftDown() && ! e.isSynthesized()) { int index = getControl().getSelectionModel().getSelectedIndex(); setAnchor(index); } --- old/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableCellBehaviorBase.java 2014-02-06 14:41:52.841996000 +0100 +++ new/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableCellBehaviorBase.java 2014-02-06 14:41:52.632984000 +0100 @@ -25,10 +25,16 @@ package com.sun.javafx.scene.control.behavior; -import javafx.scene.Node; -import javafx.scene.control.*; +import javafx.scene.control.Control; +import javafx.scene.control.IndexedCell; +import javafx.scene.control.SelectionMode; +import javafx.scene.control.TableColumnBase; +import javafx.scene.control.TableFocusModel; +import javafx.scene.control.TablePositionBase; +import javafx.scene.control.TableSelectionModel; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -74,20 +80,11 @@ * Private fields * * * **************************************************************************/ - - // For RT-17456: have selection occur as fast as possible with mouse input. - // The idea is (consistently with some native applications we've tested) to - // do the action as soon as you can. It takes a bit more coding but provides - // the best feel: - // - when you click on a not-selected item, you can select immediately on press - // - when you click on a selected item, you need to wait whether DragDetected or Release comes first + // To support touch devices, we have to slightly modify this behavior, such // that selection only happens on mouse release, if only minimal dragging // has occurred. private boolean latePress = false; - private boolean wasSelected = false; - - /*************************************************************************** * * @@ -134,17 +131,13 @@ **************************************************************************/ @Override public void mousePressed(MouseEvent event) { - boolean selectedBefore = isSelected(); - - if (isSelected()) { + if (event.isSynthesized()) { latePress = true; - return; - } - - doSelect(event); - - if (IS_TOUCH_SUPPORTED && selectedBefore) { - wasSelected = isSelected(); + } else { + latePress = getControl().isSelected(); + if (!latePress) { + doSelect(event); + } } } @@ -153,19 +146,10 @@ latePress = false; doSelect(event); } - - wasSelected = false; } @Override public void mouseDragged(MouseEvent event) { latePress = false; - - // the mouse has now been dragged on a touch device, we should - // remove the selection if we just added it in the last mouse press - // event - if (IS_TOUCH_SUPPORTED && ! wasSelected && isSelected()) { - getSelectionModel().clearSelection(getControl().getIndex()); - } } --- old/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableRowBehavior.java 2014-02-06 14:41:54.836110000 +0100 +++ new/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TableRowBehavior.java 2014-02-06 14:41:54.628098100 +0100 @@ -41,18 +41,10 @@ * * **************************************************************************/ - // For RT-17456: have selection occur as fast as possible with mouse input. - // The idea is (consistently with some native applications we've tested) to - // do the action as soon as you can. It takes a bit more coding but provides - // the best feel: - // - when you click on a not-selected item, you can select immediately on press - // - when you click on a selected item, you need to wait whether DragDetected or Release comes first - // // To support touch devices, we have to slightly modify this behavior, such // that selection only happens on mouse release, if only minimal dragging // has occurred. private boolean latePress = false; - private boolean wasSelected = false; @@ -78,44 +70,25 @@ // we only care about clicks to the right of the right-most column if (! isClickOutsideCellBounds(event.getX())) return; - boolean selectedBefore = getControl().isSelected(); - - if (getControl().isSelected()) { + if (event.isSynthesized()) { latePress = true; - return; - } - - doSelect(event); - - if (IS_TOUCH_SUPPORTED && selectedBefore) { - wasSelected = getControl().isSelected(); + } else { + latePress = getControl().isSelected(); + if (!latePress) { + doSelect(event); + } } } @Override public void mouseReleased(MouseEvent event) { - // we only care about clicks to the right of the right-most column - if (! isClickOutsideCellBounds(event.getX())) return; - if (latePress) { latePress = false; doSelect(event); } - - wasSelected = false; } @Override public void mouseDragged(MouseEvent event) { - // we only care about clicks to the right of the right-most column - if (! isClickOutsideCellBounds(event.getX())) return; - latePress = false; - - // the mouse has now been dragged on a touch device, we should - // remove the selection if we just added it in the last mouse press - // event - if (IS_TOUCH_SUPPORTED && ! wasSelected && getControl().isSelected()) { - getControl().getTableView().getSelectionModel().clearSelection(getControl().getIndex()); - } } --- old/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java 2014-02-06 14:41:56.820223500 +0100 +++ new/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TreeCellBehavior.java 2014-02-06 14:41:56.611211500 +0100 @@ -25,6 +25,7 @@ package com.sun.javafx.scene.control.behavior; +import com.sun.javafx.scene.control.Logging; import javafx.scene.Node; import javafx.scene.control.FocusModel; import javafx.scene.control.MultipleSelectionModel; @@ -34,12 +35,12 @@ import javafx.scene.control.TreeView; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; +import sun.util.logging.PlatformLogger; +import sun.util.logging.PlatformLogger.Level; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.sun.javafx.scene.control.Logging; -import sun.util.logging.PlatformLogger; -import sun.util.logging.PlatformLogger.Level; /** */ @@ -86,17 +87,10 @@ * * **************************************************************************/ - // For RT-17456: have selection occur as fast as possible with mouse input. - // The idea is (consistently with some native applications we've tested) to - // do the action as soon as you can. It takes a bit more coding but provides - // the best feel: - // - when you click on a not-selected item, you can select immediately on press - // - when you click on a selected item, you need to wait whether DragDetected or Release comes first // To support touch devices, we have to slightly modify this behavior, such // that selection only happens on mouse release, if only minimal dragging // has occurred. private boolean latePress = false; - private boolean wasSelected = false; @@ -119,17 +113,14 @@ **************************************************************************/ @Override public void mousePressed(MouseEvent event) { - boolean selectedBefore = getControl().isSelected(); - if (getControl().isSelected()) { + if (event.isSynthesized()) { latePress = true; - return; - } - - doSelect(event); - - if (IS_TOUCH_SUPPORTED && selectedBefore) { - wasSelected = getControl().isSelected(); + } else { + latePress = getControl().isSelected(); + if (!latePress) { + doSelect(event); + } } } @@ -138,22 +129,10 @@ latePress = false; doSelect(event); } - - wasSelected = false; } @Override public void mouseDragged(MouseEvent event) { latePress = false; - - TreeView treeView = getControl().getTreeView(); - if (treeView == null || treeView.getSelectionModel() == null) return; - - // the mouse has now been dragged on a touch device, we should - // remove the selection if we just added it in the last mouse press - // event - if (IS_TOUCH_SUPPORTED && ! wasSelected && getControl().isSelected()) { - treeView.getSelectionModel().clearSelection(getControl().getIndex()); - } } --- old/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TreeTableRowBehavior.java 2014-02-06 14:41:58.818337800 +0100 +++ new/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TreeTableRowBehavior.java 2014-02-06 14:41:58.610325900 +0100 @@ -43,18 +43,10 @@ * * **************************************************************************/ - // For RT-17456: have selection occur as fast as possible with mouse input. - // The idea is (consistently with some native applications we've tested) to - // do the action as soon as you can. It takes a bit more coding but provides - // the best feel: - // - when you click on a not-selected item, you can select immediately on press - // - when you click on a selected item, you need to wait whether DragDetected or Release comes first - // // To support touch devices, we have to slightly modify this behavior, such // that selection only happens on mouse release, if only minimal dragging // has occurred. private boolean latePress = false; - private boolean wasSelected = false; @@ -78,44 +70,25 @@ // we only care about clicks to the right of the right-most column if (! isClickOutsideCellBounds(event.getX())) return; - boolean selectedBefore = getControl().isSelected(); - - if (getControl().isSelected()) { + if (event.isSynthesized()) { latePress = true; - return; - } - - doSelect(event); - - if (IS_TOUCH_SUPPORTED && selectedBefore) { - wasSelected = getControl().isSelected(); + } else { + latePress = getControl().isSelected(); + if (!latePress) { + doSelect(event); + } } } @Override public void mouseReleased(MouseEvent event) { - // we only care about clicks to the right of the right-most column - if (! isClickOutsideCellBounds(event.getX())) return; - if (latePress) { latePress = false; doSelect(event); } - - wasSelected = false; } @Override public void mouseDragged(MouseEvent event) { - // we only care about clicks to the right of the right-most column - if (! isClickOutsideCellBounds(event.getX())) return; - latePress = false; - - // the mouse has now been dragged on a touch device, we should - // remove the selection if we just added it in the last mouse press - // event - if (IS_TOUCH_SUPPORTED && ! wasSelected && getControl().isSelected()) { - getControl().getTreeTableView().getSelectionModel().clearSelection(getControl().getIndex()); - } }