EVALUATION
Commit to tiger for now. We may have time to do this for merlin if we
miraculously fix everything else first.
david.mendenhall@east 2001-02-14
Name: agR10216 Date: 02/28/2003
Actually, it's possible to implement one's own drag gesture
recognizer that would utilize any given drag gesture motion
threshold. For example, one could look at
javax.swing.plaf.basic.BasicDragGestureRecognizer.
It's reasonable to add a public method for setting the
property in question and update the AWT default drag gesture
recognizers in order that setting this property takes effect
in all subsequent drag operations.
###@###.### 2003-02-28
======================================================================
Name: agR10216 Date: 06/09/2003
The following CCC request was approved on June, 5, 2003.
4415175: No easy way to globally change the DND gesture motion threshold
Problem
The AWT default mouse drag gesture recognizers [see
java.awt.dnd.DragSource.createDefaultDragGestureRecognizer()]
use a drag gesture motion threshold. Roughly speaking, this is
a number of pixels hysterisis before drag is determined to have
started when the mouse is being dragged.
Prior to this fix the AWT default drag gesture recognizers used
the value of the desktop property "DnD.gestureMotionThreshold"
[see java.awt.Toolkit.getDesktopProperty()] if it was available,
otherwise they used the default value 5. But the desktop property
"DnD.gestureMotionThreshold" was never set, so the default value
5 was always used.
With the drag gesture motion threshold presetted the way described
above, users could not change the drag threshold and one could often
get a drag when they do not want it (especially at higher resolutions).
Requestors
Java Drag & Drop team,
Robert Clevenger (Oracle)
Solution
With this fix the pertinent Windows system metrics and
XSETTING property are mapped to the Java desktop property
"DnD.gestureMotionThreshold".
However, a way for setting the drag threshold by a Java user
should be provided. On Windows, for example, there is no way
for a user to change the desktop settings pertinent to the
drag threshold. The drag threshold can even appear less than
5. On X platforms, if there is no XSETTINGS, the hard-coded
default drag threshold is employed.
From the 2 variants: a method for setting the drag threshold
and a system property specifying the drag theshold, the
latter appears to be more convenient: users could specify
the drag threshold when starting their Java programs;
besides, the former would require some mechanism to keep
track of whether or not the drag threshold has been set via
that setter method.
Continuing, the solution is to introduce the Java system
property "awt.dnd.drag.threshold"; add the method "public
static int getDragThreshold()" to the class
java.awt.dnd.DragSource; recommend mouse drag gesture
recognizers to use DragSource.getDragThreshold() [all as
decsribed in the specification section] and update the AWT
default drag gesture recognizers to follow this convention.
Interface summary
exported external method public static int java.awt.dnd.DragSource.getDragThreshold()
property awt.dnd.drag.threshold
class java.awt.dnd.MouseDragGestureRecognizer
Specification
java.awt.dnd.DragSource:
/**
* Returns the drag gesture motion threshold. The drag gesture motion threshold
* defines the recommended behavior for {@link MouseDragGestureRecognizer}s.
* <p>
* If the system property <code>awt.dnd.drag.threshold</code> is set to
* a positive integer, this method returns the value of the system property;
* otherwise if a pertinent desktop property is available and supported by
* the implementation of the Java platform, this method returns the value of
* that property; otherwise this method returns some default value.
* The pertinent desktop property can be queried using
* <code>java.awt.Toolkit.getDesktopProperty("DnD.gestureMotionThreshold")</code>.
*
* @return the drag gesture motion threshold
* @see MouseDragGestureRecognizer
* @since 1.5
*/
public static int getDragThreshold()
java.awt.dnd.MouseDragGestureRecognizer:
*** 14,30 ****
import java.awt.event.MouseMotionListener;
/**
* This abstract subclass of <code>DragGestureRecognizer</code>
* defines a <code>DragGestureRecognizer</code>
! * for mouse based gestures.
*
! * Each platform will implement its own concrete subclass of this class,
* available via the Toolkit.createDragGestureRecognizer() method,
* to encapsulate
* the recognition of the platform dependent mouse gesture(s) that initiate
* a Drag and Drop operation.
*
* @author Laurence P. G. Cable
* @version %R%.%L%
*
* @see java.awt.dnd.DragGestureListener
--- 14,43 ----
import java.awt.event.MouseMotionListener;
/**
* This abstract subclass of <code>DragGestureRecognizer</code>
* defines a <code>DragGestureRecognizer</code>
! * for mouse-based gestures.
*
! * Each platform implements its own concrete subclass of this class,
* available via the Toolkit.createDragGestureRecognizer() method,
* to encapsulate
* the recognition of the platform dependent mouse gesture(s) that initiate
* a Drag and Drop operation.
+ * <p>
+ * Mouse drag gesture recognizers should honor the
+ * drag gesture motion threshold, available through
+ * {@link DragSource#getDragThreshold}.
+ * A drag gesture should be recognized only when the distance
+ * in either the horizontal or vertical direction between
+ * the location of the latest mouse dragged event and the
+ * location of the corresponding mouse button pressed event
+ * is greater than the drag gesture motion threshold.
+ * <p>
+ * Drag gesture recognizers created with
+ * {@link DragSource#createDefaultDragGestureRecognizer}
+ * follow this convention.
*
* @author Laurence P. G. Cable
* @version %R%.%L%
*
* @see java.awt.dnd.DragGestureListener
Compatibility risk: low
Mouse drag gesture recognizers will use the value returned
from DragSource.getDragThreshold() as the drag threshold
instead of the default hard-coded value. That value can be
set by a user through the system property or a pertinent
property of the native desktop. These changes will unlikely
break existing applications.
###@###.### 2003-06-09
======================================================================
Name: agR10216 Date: 06/10/2003
Swing drag gesture recognizers will be updated
to follow the convention given in the spec of
java.awt.dnd.MouseDragGestureRecognizer under
4876520 (Swing drag gesture recognizers should
honor drag threshold).
###@###.### 2003-06-10
======================================================================
|