JDK-4327679 : MouseDragged,MouseReleased are not triggered by Button for Middle mouse button
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-04-04
  • Updated: 2000-10-11
  • Resolved: 2000-09-06
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 betaFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
In Windows,MouseDragged,MouseReleased Events are not triggered by Button for Middle mouse button when mouse is dragged and Released outside the component.

How to reproduce the Bug? -------->
Run this sample code. You would see a frame with a button at the North.
Press the Middle mouse button inside the textField and drag it.
Drag the mouse outside the button and drag it all over the screen without
releasing the mouse button. Release the mouse button when mouse pointer
is outside the button. Check whether Mouse Dragged Event,Mouse Released
Events are  triggering for button or not. 

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

EVALUATION Commit to fix in Merlin (SQE yellow bug). eric.hawkes@eng 2000-05-07 Name: biR10147 Date: 09/01/2000 ###@###.### The only way to deliver mouse events to the components when the mouse is outside the window is to capture the mouse on each pressing. As a result, notification about clicking on the button will not be sent and ACTION_PERFORMED event will not be fired. To correct this, we have to send the notifications on each MouseUp. AwtComponent defines standard behavior, and AwtButton overrides it to notify cutton of clicking (only in case of left button and if both pressing and releasing were performed inside the button). ======================================================================
11-06-2004

SUGGESTED FIX Name: biR10147 Date: 09/01/2000 ###@###.### Capture the mouse over a component where dragging started so mouse events could be delivered to the components properly. ------- awt_Component.h ------- *************** *** 500,505 **** --- 500,507 ---- BOOL m_dragged; /* in drag operation */ virtual INLINE HWND GetWrappeeHandle() { return NULL; } + virtual void AwtComponent::SetDragCapture(); + virtual void AwtComponent::ReleaseDragCapture(); private: ------- awt_Component.cpp ------- *************** *** 3749,3754 **** --- 3749,3764 ---- env->DeleteLocalRef(target); } + void AwtComponent::SetDragCapture() + { + ::SetCapture(GetHWnd()); + } + + void AwtComponent::ReleaseDragCapture() + { + ::ReleaseCapture(); + } + void AwtComponent::SendMouseEvent(long id, jlong when, long x, long y, long modifiers, long clickCount, long popupTrigger, *************** *** 3795,3800 **** --- 3805,3819 ---- env->ExceptionDescribe(); env->ExceptionClear(); } + + if (id == java_awt_event_MouseEvent_MOUSE_PRESSED) { + SetDragCapture(); + } + + if (id == java_awt_event_MouseEvent_MOUSE_RELEASED) { + ReleaseDragCapture(); + } + DASSERT(mouseEvent != NULL); if (pMsg != 0) { AwtAWTEvent::saveMSG(env, pMsg, mouseEvent); ====================================================================== Name: biR10147 Date: 09/01/2000 ###@###.### ------- awt_Button.h ------- *************** *** 33,38 **** --- 33,39 ---- static AwtButton* Create(jobject self, jobject hParent); /* Windows message handler functions */ + MsgRouting WmMouseUp(UINT flags, int x, int y, int button); MsgRouting WmNotify(UINT notifyCode); MsgRouting OwnerDrawItem(UINT ctrlId, DRAWITEMSTRUCT far& drawInfo); MsgRouting WmPaint(HDC hDC); ------- awt_Button.cpp ------- *************** *** 118,123 **** --- 118,139 ---- return c; } + MsgRouting + AwtButton::WmMouseUp(UINT flags, int x, int y, int button) + { + MsgRouting mrResult = AwtComponent::WmMouseUp(flags, x, y, button); + + POINT p = {x, y}; + RECT rect; + ::GetClientRect(GetHWnd(), &rect); + + if (::PtInRect(&rect, p) && button == LEFT_BUTTON) { + WmNotify(BN_CLICKED); + } + + return mrResult; + } + MsgRouting AwtButton::WmNotify(UINT notifyCode) { ======================================================================
11-06-2004