|
|
Re: ScrollBar.setIncrement() no effect on Linux? [message #557989 is a reply to message #557730] |
Thu, 09 September 2010 17:03 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi Markus,
For scrollbars like these that are created and owned by native controls you
cannot count on being able to control them like this. It may work on some
platforms/situations but is not guaranteed to always do so.
For the specific problem that you describe, an approach like the snippet
below should ensure that partial items are never shown as a result of
clicking on the scrollbar's up or down arrow, which is what setIncrement()
controls for Scrollbars in other contexts.
public class Main {
static int lastTopIndex = 0;
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,600,600);
final Table table = new Table(shell, SWT.V_SCROLL);
table.setBounds(10,10,500,500);
for (int i = 0; i < 99; i++) {
new TableItem(table, SWT.NONE).setText("item " + i);
}
table.getVerticalBar().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int topIndex = table.getTopIndex();
if (topIndex != lastTopIndex) {
lastTopIndex = topIndex;
table.setTopIndex(topIndex);
}
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
HTH,
Grant
"Markus Duft" <markus.duft@salomon.at> wrote in message
news:i68avn$hg1$1@build.eclipse.org...
> hm... playing some more on a windows 7 host - it doesn't work there
> either. independently of what i set the value to (and, yes, the
> setIncrement get's called, i breakpointed it ;)), scrolling behaviour
> never changes...
|
|
|
|
Powered by
FUDForum. Page generated in 0.03765 seconds