Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Scrolled composite of composite is not scrolling in linux GTK3(Scrolled composite of composite is not scrolling in linux GTK3)
Scrolled composite of composite is not scrolling in linux GTK3 [message #1704053] Thu, 06 August 2015 22:41 Go to next message
Abhishek Singh is currently offline Abhishek SinghFriend
Messages: 4
Registered: August 2015
Junior Member
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.

Is there something I am missing here or doing incorrectly?

Please advise.
Re: Scrolled composite of composite is not scrolling in linux GTK3 [message #1704923 is a reply to message #1704053] Mon, 10 August 2015 18:39 Go to previous message
Abhishek Singh is currently offline Abhishek SinghFriend
Messages: 4
Registered: August 2015
Junior Member
Looks like the issue is probably with the style of the composite.

If in the example I set the style for CustomWidget to be SWT.NONE instead of SWT.BORDER then then scrolling works in GTK3.

I have submitted a bug for this link
Previous Topic:issue with nested Composites
Next Topic:No double click event on TreeCursor
Goto Forum:
  


Current Time: Tue Mar 19 11:52:49 GMT 2024

Powered by FUDForum. Page generated in 0.04834 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top