Community
Participate
Working Groups
I have this application that has a scrolled composite containing a grid of composites. Here is the code below: import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; public class ScrolledCompositeExample { public static class CustomWidget extends Composite { public CustomWidget(Composite parent, int style) { super(parent, style); setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); RowLayout rowLayout = new RowLayout(); rowLayout.spacing = 50; setLayout(rowLayout); Label label1 = new Label(this, SWT.NONE); label1.setText("This is one label" + SWT.getVersion()); Label labelMain = new Label(this, SWT.NONE); labelMain.setText("This is another label"); Button button = new Button(this, SWT.PUSH); button.setText("This is a button "); } } public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final ScrolledComposite scrollComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.BORDER); final Composite parent = new Composite(scrollComposite, SWT.NONE); for (int i = 0; i <= 500; i++) { CustomWidget item = new CustomWidget(parent, SWT.BORDER); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 80; item.setLayoutData(gd); } GridLayout layout = new GridLayout(1, true); layout.horizontalSpacing = -1; layout.verticalSpacing = -1; parent.setLayout(layout); scrollComposite.setContent(parent); scrollComposite.setExpandVertical(true); scrollComposite.setExpandHorizontal(true); scrollComposite.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); shell.setSize(1000, 500); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } } This works properly on Windows SWT. I can scroll using the mouse scroll wheel when my mouse is over the composites. However the same code does not work on Linux GTK3 SWT. The window does not scroll when the mouse is over the composites. It only scrolls when I m over the scroll bar or when I reduce the composite to not FILL the parent composite. I really want the ability to allow scrolling over the customWidget composites since I plan to use this on a touch panel.
Does snippet5 scroll for you? http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet5.java I recall I had to use setContent(.) to get scrolling to work, but it seems like you're already usigng it in your code. Do you know which version of Gtk3?
Hi Leo, Yes the Snippet5 example works for me. Playing with the examples more I think the issue is with the SWT style BORDER Scrolling works in GTK when Composite b1 = new Composite(c1, SWT.NONE); But when I make it Composite b1 = new Composite(c1, SWT.BORDER); So in my sample below if you change the style of Custom Widget to SWT.NONE then it works in GTK3 but when I pass in SWT.BORDER then the scrolling stops. The version of GTK3 that I am using is gtk3-3.10.9-2.fc20.x86_64 Name : gtk3 Version : 3.10.9 Release : 2.fc20 Architecture: x86_64 Regards Abhishek
New Gerrit change created: https://git.eclipse.org/r/63039
This looks like duplicate of bug 479580 . Would you please try with Neon M6? It should be fixed there.
4 weeks without reply from report. Marking the bug as closed as I can't reproduce it anymore. If the problem still persists for you with latest Neon please reopen with details.