Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ScrollBar.setIncrement() no effect on Linux?
ScrollBar.setIncrement() no effect on Linux? [message #557715] Wed, 08 September 2010 11:16 Go to next message
Eclipse UserFriend
Hey!

Is there a known issue with the setIncrement Method? what i'm trying to do ist the following:

        final ScrollBar vBar2 = table.getVerticalBar();
        if (vBar2 != null) {
            vBar2.setIncrement(table.getItemHeight());
        }


that seems to work on windows, and have no effect on linux. the plan is, that the table scrolls only one items height at a time (so i can guarantee, that the topmost item is always shown completely). linux is off by one or two pixels per item, resulting in what i don't want: half shown items.

completely removeing the above code, the scrolling behaviour stays exactly the same, and setting the increment to 100 also has no effect at all...?!

any insights?

Thanks!
Rgards, Markus
Re: ScrollBar.setIncrement() no effect on Linux? [message #557730 is a reply to message #557715] Wed, 08 September 2010 11:43 Go to previous messageGo to next message
Eclipse UserFriend
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 Wink), scrolling behaviour never changes...
Re: ScrollBar.setIncrement() no effect on Linux? [message #557989 is a reply to message #557730] Thu, 09 September 2010 13:03 Go to previous messageGo to next message
Eclipse UserFriend
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...
Re: ScrollBar.setIncrement() no effect on Linux? [message #558488 is a reply to message #557989] Mon, 13 September 2010 04:50 Go to previous message
Eclipse UserFriend
hey, thanks a lot Wink

good to know i can't rely on this. and thanks for the snippet - i'll try this asap Smile

regards, markus
Previous Topic:Re: Deselecting a table item on second selection
Next Topic:Reordering widgets within composite
Goto Forum:
  


Current Time: Wed Jul 23 14:25:58 EDT 2025

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

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

Back to the top