JDK-4338368 : In Windows, Mouse Events are triggered by choice when it loses focus
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-05-16
  • Updated: 2001-01-06
  • Resolved: 2000-10-31
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 :  
Description
In Windows:
When focus is transferred from choice to some other component, choice triggers mouse events when mouse is not at all near the choice and no mouse operation is performed. This is noticed in merlin-beta.

How to reproduce the Bug? -------->
Run this sample code. You would see a frame with a choice at the center,a button and a textfield. Transfer the focus from choice to to either button or textfield by clicking them or by pressing the TAB key. If you notice any of the mouse events being triggered for choice then the bug is reproduced.

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-16 Name: biR10147 Date: 10/10/2000 ###@###.### In Windows the native ComboBox triggers spurious MouseUp when it loses focus, even if the focus was lost due to the keyboard manipulations (i.e., pressing the TAB key). When we saw such event, we had no idea it is spurious and proceeded it in a normal way, creating MOUSE_RELEASED and MOUSE_CLICKED, which resulted in a bug. To prevent such behaviour, we should override WmKillFocus and WmMouseUp in awt_Choice.cpp to keep track of these events and consume extra event right after it was triggered. ======================================================================
11-06-2004

SUGGESTED FIX Name: biR10147 Date: 10/10/2000 ###@###.### Consume spurious WM_MOUSEUP events. ------- awt_Choice.h ------- *************** *** 48,53 **** --- 48,57 ---- MsgRouting OwnerDrawItem(UINT ctrlId, DRAWITEMSTRUCT far& drawInfo); MsgRouting OwnerMeasureItem(UINT ctrlId, MEASUREITEMSTRUCT far& measureInfo); + /* Workaround for bug #4338368 */ + MsgRouting WmKillFocus(HWND hWndGotFocus); + MsgRouting WmMouseUp(UINT flags, int x, int y, int button); + INLINE HWND GetDBCSEditHandle() { return GetHWnd(); } virtual void SetFont(AwtFont *pFont); virtual BOOL InheritsNativeMouseWheelBehavior(); *************** *** 56,61 **** --- 60,66 ---- virtual void ReleaseDragCapture(); private: + BOOL AwtChoice::consumeNextMouseUp; int GetFieldHeight(); int GetTotalHeight(); }; ------- awt_Choice.cpp ------- *************** *** 22,27 **** --- 22,31 ---- /* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code. */ + /* Bug #4338368: consume the spurious MouseUp when the choice loses focus */ + + BOOL consumeNextMouseUp = FALSE; + /************************************************************************* * AwtChoice class methods */ *************** *** 291,296 **** --- 295,321 ---- return mrConsume; } + /* Bug #4338368: when a choice loses focus, it triggers spurious MouseUp event, + * even if the focus was lost due to TAB key pressing + */ + + MsgRouting + AwtChoice::WmKillFocus(HWND hWndGotFocus) + { + consumeNextMouseUp = TRUE; + return AwtComponent::WmKillFocus(hWndGotFocus); + } + + MsgRouting + AwtChoice::WmMouseUp(UINT flags, int x, int y, int button) + { + if (consumeNextMouseUp) { + consumeNextMouseUp = FALSE; + return mrConsume; + } + return AwtComponent::WmMouseUp(flags, x, y, button); + } + BOOL AwtChoice::InheritsNativeMouseWheelBehavior() {return true;} /************************************************************************ ======================================================================
11-06-2004