JDK-4494085 : Need to allow right-click through WMouseDragGestureRecognizer
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-08-20
  • Updated: 2001-09-18
  • Resolved: 2001-09-18
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 Availability Release.

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

Name: nt126004			Date: 08/20/2001


java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

Not sure if this should be a bug or a feature, but perhaps a feature...

Since there is no apparent way for an application to register a subclass the
MouseDragGestureRecognizer, there needs to be a way to enable the 'right-click'
drag as a drag gesture. I believe that in my environment it is the
sun.awt.windows.WMouseDragGestureRecognizer that is ignoring the right mouse
button as a potential drag gesture.

I realize that the right-click is also a popup event, but the component needs
to be able to support both and may opt for one or the other. For example, the
mouse drag threshold (I think its 5 by default), might be increased to 10
pixels so that anything less than 10 pixels would cause a popup menu and
anything greater would cause a 'right-click' drag gesture.
(Review ID: 130219) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: merlin-beta3 INTEGRATED IN: merlin-beta3
14-06-2004

EVALUATION Name: dsR10078 Date: 09/13/2001 Currently only left mouse button drags are allowed by the default DragGestureRecognizer on Win32. There are no reasons to disable right or middle mouse button drags on Win32. On Solaris/Linux the default DragGestureRecognizer allows to drag with any mouse button. However if you drag with a right mouse button the drag operation will not be terminated when you release the button, since the Motif DnD (which the Solaris/Linux implementation of AWT DnD subsystem is based on) terminates the drag only when either the left or the middle mouse button is released. ###@###.### 2001-09-13 ======================================================================
13-09-2001

WORK AROUND Name: nt126004 Date: 08/20/2001 Customer Workaround: The sun.awt.windows.WMouseDragGestureRecognizer can be replaced by using the - Xbootclasspath/p: option. This is neither cross-platform nor a real solution. ====================================================================== Name: dsR10078 Date: 09/13/2001 Use a custom drag gesture recognizer. A sample code: -------------------------------------------------------------------------- import java.awt.Component; import java.awt.Label; import java.awt.Frame; import java.awt.Point; import java.awt.datatransfer.StringSelection; import java.awt.dnd.DnDConstants; import java.awt.dnd.DragSource; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragGestureRecognizer; import java.awt.dnd.MouseDragGestureRecognizer; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class CustomDragGestureRecognizerApp { public static final int MOTION_THRESHOLD = 10; final Frame frame = new Frame(); final Label label = new Label("Drag me!"); final WindowAdapter windowAdapter = new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.dispose(); } }; final DragSource dragSource = new DragSource(); final DragGestureListener dragGestureListener = new DragGestureListener() { public void dragGestureRecognized(DragGestureEvent dge) { dge.startDrag(null, new StringSelection(label.getText())); } }; final DragGestureRecognizer dragGestureRecognizer = new CustomDragGestureRecognizer(dragSource, label, DnDConstants.ACTION_COPY, dragGestureListener, MOTION_THRESHOLD); public static void main(String[] args) { new CustomDragGestureRecognizerApp(); } public CustomDragGestureRecognizerApp() { frame.add(label); frame.pack(); frame.addWindowListener(windowAdapter); frame.setVisible(true); } } class CustomDragGestureRecognizer extends MouseDragGestureRecognizer { final int motionThreshold; public CustomDragGestureRecognizer(DragSource ds, Component c, int act, DragGestureListener dgl, int motionThreshold) { super(ds, c, act, dgl); this.motionThreshold = motionThreshold; } public void mousePressed(MouseEvent e) { resetRecognizer(); if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { appendEvent(e); } } public void mouseReleased(MouseEvent e) { resetRecognizer(); } public void mouseDragged(MouseEvent e) { if (getTriggerEvent() != null) { // gesture pending if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0) { appendEvent(e); final MouseEvent trigger = (MouseEvent)getTriggerEvent(); final Point origin = trigger.getPoint(); final Point current = e.getPoint(); final int dx = Math.abs(origin.x - current.x); final int dy = Math.abs(origin.y - current.y); if (dx > motionThreshold || dy > motionThreshold) { fireDragGestureRecognized(DnDConstants.ACTION_COPY, origin); } } else { resetRecognizer(); } } } } -------------------------------------------------------------------------- ###@###.### 2001-09-13 ======================================================================
13-09-2001

SUGGESTED FIX Name: dsR10078 Date: 09/13/2001 Modify the MMouseDragGestureRecognizer to allow only left or middle mouse button drags. Modify the WMouseDragGestureRecognizer to allow drags with any mouse button. ###@###.### 2001-09-13 ======================================================================
13-09-2001