modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ListCellBehavior.java
Print this page
@@ -23,23 +23,24 @@
* questions.
*/
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;
import javafx.scene.control.MultipleSelectionModel;
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;
/**
*/
public class ListCellBehavior<T> extends CellBehaviorBase<ListCell<T>> {
@@ -82,22 +83,14 @@
* *
* 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;
/***************************************************************************
* *
* Constructors *
@@ -117,40 +110,30 @@
**************************************************************************/
@Override public void mousePressed(MouseEvent event) {
boolean selectedBefore = getControl().isSelected();
- if (getControl().isSelected()) {
+ if (event.isSynthesized()) {
latePress = true;
return;
- }
-
+ } else {
+ latePress = getControl().isSelected();
+ if (!latePress) {
doSelect(event);
-
- if (IS_TOUCH_SUPPORTED && selectedBefore) {
- wasSelected = getControl().isSelected();
+ }
}
}
@Override public void mouseReleased(MouseEvent event) {
if (latePress) {
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());
- }
}
/***************************************************************************