Scrolled composite of composite is not scrolling in linux GTK3 [message #1704053] |
Thu, 06 August 2015 22:41 |
Abhishek Singh 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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04834 seconds