Bug 118049 - [CCombo] CCombo in form : dropdown scrolling causes parent shell to scroll too
Summary: [CCombo] CCombo in form : dropdown scrolling causes parent shell to scroll too
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.6 RC1   Edit
Assignee: Lakshmi P Shanmugam CLA
QA Contact: Carolyn MacLeod CLA
URL:
Whiteboard:
Keywords: ui, usability
: 275885 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-11-25 08:19 EST by Antoine Angénieux CLA
Modified: 2010-05-11 06:28 EDT (History)
11 users (show)

See Also:
grant_gayed: review+


Attachments
Error example in eclipse product editor (22.00 KB, image/gif)
2005-11-25 08:35 EST, Antoine Angénieux CLA
no flags Details
Another example on an application of mine (15.27 KB, image/gif)
2005-11-25 08:37 EST, Antoine Angénieux CLA
no flags Details
simple plugin for scrolled form view (3.30 KB, application/octet-stream)
2009-04-20 17:19 EDT, Lakshmi P Shanmugam CLA
no flags Details
patch (2.81 KB, patch)
2009-07-14 10:53 EDT, Lakshmi P Shanmugam CLA
no flags Details | Diff
test case - CCombo inside a Scrollable composite (2.34 KB, text/java)
2009-07-14 10:55 EDT, Lakshmi P Shanmugam CLA
no flags Details
movie (3.88 MB, application/x-shockwave-flash)
2010-01-11 16:33 EST, Kevin Barnes CLA
no flags Details
final patch (2.83 KB, patch)
2010-05-10 12:58 EDT, Grant Gayed CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Angénieux CLA 2005-11-25 08:19:15 EST
When scrolling vertically in the drop down, either with the keyboard keys or a click on the scroll bar, if the CCombo is in a form nested in a Shell that also has a vertical scroll bar, the shell scrolls in the sameway the CCombo drop down does.
Comment 1 Antoine Angénieux CLA 2005-11-25 08:35:39 EST
Created attachment 30607 [details]
Error example in eclipse product editor

The drop down containing the value for the CCombo 
"Specify the application to run when launching this product" is way below the CCombo text field, because the parent shell scroll bar "followed" the one from te CCombo drop down.
Comment 2 Antoine Angénieux CLA 2005-11-25 08:37:41 EST
Created attachment 30608 [details]
Another example on an application of mine

Again, the drop down showing the possible values of the CCombo labelled "F.E. visuelle", is way below its defining CCombo as the containing ScrollableForm "followed" scrolling the drop-down scrolling.
Comment 3 Antoine Angénieux CLA 2005-11-25 08:40:25 EST
In fact, it is not linked to the fact that the parent shell has a vertical scroll bar, but that the CCombo is within a Scrollable container.
Comment 4 Steve Northover CLA 2007-06-20 18:35:58 EDT
This is probably not a CCombo bug.  Duong to prove this by writing a simple test case that shows a popup list also scrolls badly.  Then give the bug to me or Felipe.
Comment 5 Evan Hourigan CLA 2008-02-19 19:22:05 EST
Is it possible that listeners are being added to do the scrolling by virtue of calling formToolkit.adapt(ccombo, true, true) on the control? 
Comment 6 Steve Northover CLA 2008-02-20 09:43:50 EST
Duong?
Comment 7 Lakshmi P Shanmugam CLA 2009-04-20 17:06:41 EDT
This behavior is not reproducible in 3.5M6. Verified it in eclipse product editor.
Also verified it by creating a sample view which uses a scrolled form.
Comment 8 Lakshmi P Shanmugam CLA 2009-04-20 17:19:09 EDT
Created attachment 132508 [details]
simple plugin for scrolled form view
Comment 9 Lakshmi P Shanmugam CLA 2009-06-23 16:55:17 EDT
I was testing a different bug using Scrolled Composite and CCombo and was able to reproduce this bug, but with different steps.
It is reproducible with 3.5RC3, using a simple SWT snippet with CCombo inside a ScrolledComposite.
Steps:
1) Click on the CCombo's arrow button so that the drop-down pops up.
2) While the dropdown is still popped-up, try to scroll the Composite (don't scroll the dropdown or the CCombo)

-------------------------------------
SWT Snippet to reproduce the problem:
-------------------------------------

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class ComboScroll {
    public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setLayout(new GridLayout());
	final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER
		| SWT.H_SCROLL | SWT.V_SCROLL);
	sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	Composite c = new Composite(sc, SWT.NONE);
	c.setLayout(new GridLayout(1, true));
	CCombo ccombo = new CCombo(c, SWT.BORDER);
	for (int i = 0; i < 5; i++)
	    ccombo.add("ccombo " + i);
	
	Combo combo = new Combo(c, SWT.BORDER);
	for (int i = 0; i < 5; i++)
	    combo.add("combo " + i);
	for (int i = 0; i < 10; i++) {
	    Button b = new Button(c, SWT.PUSH);
	    b.setText("Button " + i);
	}
	    
	sc.setContent(c);
	sc.setExpandHorizontal(true);
	sc.setExpandVertical(true);
	sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	sc.setShowFocusedControl(true);
	shell.setSize(300, 300);
	shell.open();
	while (!shell.isDisposed()) {
	    if (!display.readAndDispatch())
		display.sleep();
	}
	
	display.dispose();
    }
}
Comment 10 Carolyn MacLeod CLA 2009-06-29 15:13:19 EDT
Lakshmi, please see if you can find a fix for this.
Comment 11 Lakshmi P Shanmugam CLA 2009-07-14 10:53:54 EDT
Created attachment 141527 [details]
patch 

This behavior is seen with CCombo on all platforms.

The patch modifies the behavior such that, when the CCombo's drop-down is visible and the user tries to scroll the containing composite, the drop-down is closed and the composite is scrolled.

The bug is seen on Windows and Carbon native Combo too. The patch doesn't fix the native Combo behavior.
Comment 12 Lakshmi P Shanmugam CLA 2009-07-14 10:55:56 EDT
Created attachment 141528 [details]
test case - CCombo inside a Scrollable composite
Comment 13 Lakshmi P Shanmugam CLA 2010-01-08 08:48:12 EST
*** Bug 275885 has been marked as a duplicate of this bug. ***
Comment 14 Kevin Barnes CLA 2010-01-11 16:33:00 EST
Created attachment 155799 [details]
movie

I don't any improvement with the patch. It's possible that I'm misunderstanding the bug though.
There are some problems with scrolling with the mouse wheel while the CCombo is open. I've attached a screen cast of bad scrolling behaviors. You'll notice that if the mouse is over the parent composite, it's scrolled, but the CCombo's popup does not. Also if the mouse is over the CCompo's popup, the mouse wheel gets delivered to the app behind the active app (see package explorer scrolling in the background).
I get the same behavior with and without the patch.

(sorry about the poor quality of the screen cast.)
Comment 15 Kevin Barnes CLA 2010-01-11 16:52:13 EST
the package explorer scrolling thing is only happening with Combo, not CCombo so that's not related to this bug. Seems that something is wrong with MouseWheel events though.
Comment 16 Lakshmi P Shanmugam CLA 2010-01-18 09:45:55 EST
Hi Kevin,
I tried to reproduce this bug on windows and currently not able to see it. I was able to reproduce it on windows before. :( 
The problem seen in the movie is the bug. When we scroll the composite with the CCombo drop-down is visible, the drop-list is still visible and detached from the CCombo. I can easily reproduce this on Linux-Gtk & Mac and applying the patch fixes the scrolling issue.
I'll try to find another windows machine to reproduce this bug.
Comment 17 Lakshmi P Shanmugam CLA 2010-03-18 09:26:42 EDT
I tried this bug on another Windows machine but I'm not able to reproduce this on windows anymore. Does anybody see this on windows with the 3.6 latest?
As before, it is reproducible on the other platforms - cocoa, carbon, gtk.
Comment 18 Lakshmi P Shanmugam CLA 2010-05-05 11:31:32 EDT
This is an usability bug still happening on Mac & GTK. 
Carolyn, can it go for RC1?
Comment 19 Grant Gayed CLA 2010-05-10 12:58:03 EDT
Created attachment 167756 [details]
final patch

Lakshmi, the patch just needs the following change:

if (event.widget instanceof ScrollBar && event.type == SWT.Selection) {
	handleScroll(event);
	return;
}

should become:

if (event.type == SWT.Selection) {
	if (event.widget instanceof ScrollBar) {
		handleScroll(event);
	}
	return;
}

Though the first block above doesn't cause a problem under normal circumstances, it did lead to a ClassCastException in the subsequent "Shell shell = ((Control)event.widget).getShell ();" line when stepping through a debugger if I selected something like a ToolItem.

Here is a patch that's identical to yours but with this change added.  Please commit this patch to HEAD, I'll +1 the report in the next comment.
Comment 20 Lakshmi P Shanmugam CLA 2010-05-11 06:28:54 EDT
Thanks Grant.
Fixed in HEAD > 20100511