JDK-4415175 : No easy way to globally change the DND gesture motion threshold
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2001-02-14
  • Updated: 2017-05-16
  • Resolved: 2003-07-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description

Name: mt13159			Date: 02/14/2001


Problem
~~~~~~~
5 is way too small of a value for the gestureMotionThreshold, and there is no easy way to change it globally.

The safest way is to get the MouseDragGestureRecognizer from DragSource which invokes the java.awt.Toolkit to get the appropriate MouseDragGestureRecognizer for a given platform.  The value from here comes from Toolkit.getDesktopProperty() which cannot be changed (since the method Toolkit.setDesktopProperty is protected).

In Swing you can use the UIDefaults class to override certain default behavior, but not this.  With the drag motion threshold set at 5, you VERY often get a drag when you do not want one (especially at higher resolutions).  There is no easy way to change it w/o using your own DragSource and DragGestureRecognizer (which may have quirks on some platforms, since you are defeating the built in behavior).

Please allow either (a) some other way to get the gestureMotionThreshold or (b) make Toolkit.setDesktopProperty public, or (c) some other solution to this problem.

Thanks!
(Review ID: 112646) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b11
2004-08-24

WORK AROUND Name: mt13159 Date: 02/14/2001 None feasible -- Implment your own DragSource and DragGestureRecognizer and hope it works as expected on most platforms. ======================================================================
2004-08-24

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 ======================================================================
2003-06-10

SUGGESTED FIX Name: agR10216 Date: 02/28/2003 Add public static methods get/setDragGestureMotionThreshold() to the DragSource class and modify WMouseDragGestureRecognizer and MMouseDragGestureRecognizer so that they get the current drag gesture motion threshold at the beginning of every drag operation. ###@###.### 2003-02-28 ======================================================================
2003-02-28