JDK-4035189 : MAJOR! Drag events and mouse released events not delivered if mouse is moved qui
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1,1.1.1,1.1.4,1.1.5,1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_95,windows_nt
  • CPU: generic,x86
  • Submitted: 1997-02-27
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
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 Other
1.1.7 b01Fixed 1.2.0Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description

Name: mc57594			Date: 02/27/97


1) In the example given, click in the red area and move the mouse 
out of the red area quickly. Note that DRAG events are not delivered.
In addition the mouse released event is not delivered when the mouse
is released. When the red component receives two mouse downs in a row
without a mouse up it will print ERROR: in the output window.

2) Source Code: (Stand Alone Example)
import java.awt.*;
import java.awt.event.*;

class DragBug
    extends Panel
{
        public DragBug()
        {
            addMouseMotionListener(new IMouseMotionAdapter());
            addMouseListener(new IMouseAdapter());
            setBackground(Color.red);
        }

        public Dimension preferredSize()
        {
            return new Dimension(50,50);

        }


        class IMouseMotionAdapter extends MouseMotionAdapter
        {
            public IMouseMotionAdapter(){}

            public void mouseDragged(MouseEvent e)
            {
                System.out.println("DragBug: DragEvent");
            }

        }

        class IMouseAdapter extends MouseAdapter
        {
             public IMouseAdapter(){}

             public void mousePressed(MouseEvent e)
             {
                System.out.println("DragBug: MousePressed");

                if (ivHasMouse)
                {
                    System.out.println("ERROR: Mouse pressed in a row without release!!");
                }

                ivHasMouse = true;
             }

             public void mouseReleased(MouseEvent e)
             {
                System.out.println("DragBug: MouseReleased");
                ivHasMouse = false;
             }
        }

        public boolean ivHasMouse = false;

}


public class DragBugDemo
{
        public static void main(String args[])
        {
            Frame f = new Frame("DragBug");
            f.setLayout(new FlowLayout());
            f.add(new DragBug());
            f.setBounds(new Rectangle(20,20,300,300));
            f.show();

        }


}

3) No error messages. Behvaior BUG

4) Trace from program. Notice the two mouse pressed events.
and no drag events. 
DragBug: DragEvent
DragBug: MouseReleased
DragBug: MousePressed
DragBug: MousePressed
ERROR: Mouse pressed in a row without release!!
DragBug: MouseReleased
DragBug: MousePressed
DragBug: MouseReleased


5)Plain Win 95
company - Shafir Inc. , email - ###@###.###
======================================================================

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

WORK AROUND Name: mc57594 Date: 02/27/97 Unknown at this time. ====================================================================== Bug is in Win32 native code; no workaround feasible.
11-06-2004

PUBLIC COMMENTS Mouse events would not get delivered if you dragged quickly off a component. This has now been fixed.
10-06-2004

EVALUATION jeff.dunn@Eng 1997-12-15 I verified that this bug still exists on NT4.0. It does not exist on Solaris/sparc. ------------ This bug is due to the fact that SetCapture() is being called from within the WM_MOUSEMOVE handler in awt_Canvas.cpp. WM_MOUSEMOVE messages are normally not delivered to a window if the mouse it outside its bounds. Calling SetCapture(HWND) ensures that mouse message get delivered regardless of where the mouse is. If the user moves the mouse quickly enough outside the window after clicking, the window will never receive a WM_MOUSEMOVE to trigger the SetCapture call. This can be verified with the Spy++ utility. The only solution can be to SetCapture() from within the WM_LBUTTONDOWN handler (which is what most Win32 apps do). robi.khan@eng 1998-04-23 This bug is also causing the drag events to go to the wrong component. The component the mouse is over ends up capturing the mouse even though the initial press was in another component. We definitely have to capture the mouse on button down. robi.khan@eng 1998-04-28 Related bug 4074498 (mouse press on title bar) also fixed in the same way. The original reason (see 4018262) for capturing on a mouse drag instead of mouse down was to prevent the capture from interfering with buttons and scrollbars. Capturing on button down will not interfere however, since Win32 controls always release the capture on button up (verified with Spy++). Problems would occur with the old code, since the capture could be 'stolen' from another control that had it. robi.khan@eng 1998-05-06
06-05-1998