JDK-4449139 : Mouse Wheel Event is not generated by Scrollbar when mouse wheel is rotated
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2001-04-22
  • Updated: 2001-08-16
  • Resolved: 2001-08-07
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 beta2Fixed
Related Reports
Relates :  
Description
Mouse Wheel Events must be triggered by Components when mouse wheel is rotated above the Component ... but Scrollbar and JScrollbar is not generating any mouse wheel event and also its not scrolling ..

Compile and Run ScrollbarMouseWheelTest
Rotate Mouse Wheel over Scrollbar and JScrollbar and see if its generating Mouse Wheel Event and also scrolling .... if its not happening bug is reporduced .

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

SUGGESTED FIX The fix for MouseWheelEvent delivery from Scrollbars on Linux would involve adding a ButtonPress handler to recognize Button 4 and Button 5 (interpreted as wheel up and wheel down) and generate MouseWheelEvents: ------- awt_Scrollbar.c ------- *** /tmp/sccs.OZaWO1 Wed Aug 1 21:23:09 2001 --- awt_Scrollbar.c Wed Aug 1 21:22:41 2001 *************** *** 14,19 **** --- 14,20 ---- #include "awt_p.h" #include "java_awt_Scrollbar.h" + #include "java_awt_event_MouseEvent.h" #include "sun_awt_motif_MScrollbarPeer.h" #include "sun_awt_motif_MComponentPeer.h" *************** *** 27,32 **** --- 28,37 ---- extern struct MComponentPeerIDs mComponentPeerIDs; extern AwtGraphicsConfigDataPtr copyGraphicsConfigToPeer(JNIEnv *env, jobject this); + void Scrollbar_ButtonPressHandler(Widget w, + XtPointer data, + XEvent *event, + Boolean *cont); /* fieldIDs for java.awt.Scrollbar fields that may be accessed from C */ *************** *** 328,339 **** --- 333,371 ---- XtAddEventHandler(w, ButtonReleaseMask, False, awt_motif_Scrollbar_ButtonReleaseHandler, NULL); + /* Set up handler to generate mouse wheel events */ + XtAddEventHandler(w, ButtonPressMask, False, + Scrollbar_ButtonPressHandler, globalRef); + XtSetMappedWhenManaged(w, False); XtManageChild(w); AWT_UNLOCK(); } + void + Scrollbar_ButtonPressHandler(Widget w, + XtPointer data, + XEvent *event, + Boolean *cont) { + + jint modifiers = getModifiers(event->xbutton.state) | + getChangedModifiers(event->xbutton.button); + + *cont = True; + if (event->xbutton.button == 4 || + event->xbutton.button == 5) { + *cont = False; + awt_post_java_mouse_event(data, + java_awt_event_MouseEvent_MOUSE_WHEEL, + NULL, /* don't pass copy of event */ + event->xbutton.time, + modifiers, + (jint) event->xbutton.x, + (jint) event->xbutton.y, + 1, False, + event->xbutton.button == 4 ? -1 : 1); + } + }
11-06-2004

EVALUATION Commit to fix in merlin-beta2. eric.hawkes@eng 2001-04-23 Reproducible as of b69. brent.christian@eng 2001-06-25 As of b72, MouseWheelEvents are correctly being delivered to both java.awt.Scrollbar and javax.swing.JScrollBar on Windows, but on Linux Scrollbars aren't getting events. Unlike ScrollPane and JScrollPane, Scrollbar and JScrollBar do not have a default behavior for the mouse wheel, though it is very easy to add a handler for mouse wheel events. ScrollPane and JScrollPane are sufficient for the vast majority of scrolling tasks. However, while playing with the test, I did notice some strange behavior on Windows. The components in the test are layed out in the Frame as follows: [JScrollBar][Label][Scrollbar] Though the wheel events are correctly delivered, when the mouse wheel is rotated when the cursor is over the JScrollBar, the Scrollbar (on the other side of the Frame) is adjusted. Clearly, this is incorrect behavior. It's as if a ScrollPane were added, instead of a Scrollbar. After more experimentation, I learned that this is true if additional Swing components are added in the "middle" of the window - a JButton, for instance. The problem goes away if another heavyweight component (such as a Button) are added. The problems also disappear if the Scrollbar is the left-most Component in the Frame. So, the following configurations yield broken behavior: [JScrollBar][Label][Scrollbar] [JScrollBar][JButton][Label][Scrollbar] The following are okay: [JScrollBar][Button][Label][Scrollbar] [Scrollbar][Label][JScrollBar] This should probably be opened as a separate bug. brent.christian@eng 2001-07-20 Fixed by adding a ButtonPress event handler of Scrollbars. See suggested fix. brent.christian@eng 2001-08-02 A new bug has been filed for the strange behavior on Windows, bug 4487750. brent.christian@eng 2001-08-02
02-08-2001