Bug 207135 - MouseWheel events doesn't works.
Summary: MouseWheel events doesn't works.
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-23 05:18 EDT by Arnaud CLA
Modified: 2019-09-06 15:36 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arnaud CLA 2007-10-23 05:18:22 EDT
Build ID: M20070212-1330

Steps To Reproduce:
Uses the snippet provided in More Information area (see below).
Launch the snippet.
When focus control is on one of check button, push button or text on the right the MouseWheel events doesn't works.
Events seems to be consumed by the ScrolledComposite parent's of those widget even if this composite have no scrollbar.

In that case MouseWheel events, as thay produce no action, should be passed to ScrolledComposite parent's.
In this snippet this will scrolls the outer ScrolledComposite which display the vertical scrollbar on the right.

Please note, when focus is on the List (on the left), MouseWheel scrolls the list as expected. 
When the focus in on Add or Remove button (on the center),
MouseWheel events scrolls then outer Scrolledcomposite as expected.

Note also that many browser passe MouseWheel events to parent's composite when the scrollbar is at min or max location (the case for IE).


More information:
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;

public class TestMouseWheel2 
{
	 public static void main(String[]args)
	 {
			final Display display = new Display();
			final Shell shell = new Shell(display);
			shell.setLayout( new GridLayout() );
			shell.setText("MouseWheel test");

			ScrolledComposite sc = new ScrolledComposite( shell, SWT.H_SCROLL|SWT.V_SCROLL );
			sc.setLayout( new GridLayout() );
			sc.setLayoutData( new GridData( GridData.FILL_BOTH|GridData.GRAB_HORIZONTAL|GridData.GRAB_VERTICAL ));
			
					
			Composite cn0 = new Composite( sc, SWT.NONE );
			sc.setContent( cn0 );
			cn0.setLayout( new GridLayout() );
			cn0.setLayoutData( new GridData(GridData.FILL_BOTH));
			
			Composite cn = new Composite( cn0, SWT.NONE );
			cn.setLayout( new GridLayout(3,false) );
			List list = new List( cn, SWT.H_SCROLL|SWT.V_SCROLL );
			list.setItems( new String[]{"Value 1","Value........ 2","Value ...........ooOOOO|OOOOoo...... 3"} );
			GridData gd = new GridData(GridData.GRAB_VERTICAL|GridData.FILL_VERTICAL);
			gd.widthHint = 75 ;
			list.setLayoutData( gd );
			
			Composite cb = new Composite( cn, SWT.NONE );
			cb.setLayout( new GridLayout() );
			(new Button(cb,SWT.PUSH)).setText("Add");
			(new Button(cb,SWT.PUSH)).setText("Remove");
			cb.setLayoutData( new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
			
			ScrolledComposite sc2 = new ScrolledComposite( cn, SWT.H_SCROLL );//|SWT.V_SCROLL );
			sc2.setLayout( new GridLayout() );
			sc2.setLayoutData( new GridData( GridData.FILL_BOTH|GridData.GRAB_HORIZONTAL ));

			Composite cn2 = new Composite( sc2, SWT.NONE );
			sc2.setContent( cn2 );
			cn2.setLayout( new GridLayout());
			cn2.setLayoutData( new GridData( GridData.FILL_BOTH|GridData.GRAB_HORIZONTAL));
			(new Button(cn2,SWT.CHECK)).setText("Here is a pretty check button");
			(new Button(cn2,SWT.PUSH)).setText("There a pushable button vefry smart");
			Text txt = new Text(cn2,SWT.SINGLE|SWT.BORDER);
			txt.setText("Now a little text.");
			txt.setLayoutData( new GridData(GridData.FILL_HORIZONTAL));
			
			sc2.setExpandHorizontal(true);
			sc2.setExpandVertical(false);
			Point size  = cn2.computeSize(SWT.DEFAULT, SWT.DEFAULT);
			cn2.setSize( size );
			sc2.setMinSize( size );
			size.x = size.x-30;
			
			//allow h_scroll of 2nd Scrolledcomposite to appear when resizing down shell.
			gd = new GridData( GridData.FILL_BOTH );
			gd.widthHint = 300 ;
			cn.setLayoutData( gd );

			
			sc.setExpandHorizontal(true);
			sc.setExpandVertical(false);
			size  = cn0.computeSize(SWT.DEFAULT, SWT.DEFAULT);
			cn0.setSize( size );
			sc.setMinSize( size );
			
			shell.setSize(450, 150);
			shell.open();
			
			while (!shell.isDisposed()) {
				if (!display.readAndDispatch())
					display.sleep();
			}
			display.dispose();
		}
}
Comment 1 Steve Northover CLA 2007-10-30 02:48:30 EDT
I'm pretty sure this is not what the platform does.  FH to confirm and then close this bug as WONTFIX (if he agrees).
Comment 2 Felipe Heidrich CLA 2007-10-31 14:57:17 EDT
mouse wheel events do go up the hierarchy as you said.

In your test case, the ScrollComposite named sc2 has a scrollbar bar (enabled, not visible). This scrollbar is first scrollbar in the hierarchy and it is the one consuming the events.

The fix your app you need to subclass ScrolledComposite and override layout(Composite, boolean) to disable the scrollbars when they hostBounds is greater than contentBounds.
Comment 3 Arnaud CLA 2007-11-02 04:51:48 EDT
ScrolledComposite's layout choose to set scrollbar visible or not depending on its content's size versus its client area.  I don't understand why at this time ScrolledComposite won't fix the scrollbar enablement too.
Why all ScrolledComposite users must subclass it to fix scrollbar enablement when this can be done once by swt.custom code ?
Comment 4 Felipe Heidrich CLA 2008-03-11 18:09:22 EDT
Steve, does it make sense to send selection events to a not visible scrollbar ?
We can change this in ScrollComposite or in Scrollable.
Comment 5 Felipe Heidrich CLA 2008-03-11 18:18:46 EDT
(In reply to comment #4)
> Steve, does it make sense to send selection events to a not visible scrollbar ?
> We can change this in ScrollComposite or in Scrollable.

Just to be clear, these selection events are generate by the mouse wheel.
Comment 6 Eclipse Webmaster CLA 2019-09-06 15:36:43 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.