ScrolledComposite scrolling in tiny steps if I click in the scroll bar [message #521960] |
Fri, 19 March 2010 13:19 |
Dominik Stadler Messages: 3 Registered: July 2009 |
Junior Member |
|
|
Hi,
I am trying to use ScrolledComposite with SWT/Eclipse 3.5.2 and was trying out the snippets at http://www.eclipse.org/swt/snippets/#scrolledcomposite
What I found is that each of the snippets shows a strange scrolling behavior. If I click into the scrollbar region, I usually expect the area to scroll by one page. However what happens with ScrolledComposite is that it only scrolls a bit, much less than a page.
I found Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=39934 which handles this problem, but there no progress since 2004.
I also found http://stackoverflow.com/questions/858591/how-do-you-change- a-scrolledcomposites-horizontal-scroll-increment, which proposes a workaround, however this does not work for me.
What do I need to make this work?
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
public class Snippet5_WithPageScroll {
public static void main (String [] args)
{
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
// this button is always 400 x 400. Scrollbars appear if the window is resized to be
// too small to show part of the button
final ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
Button b1 = new Button(c1, SWT.PUSH);
b1.setText("fixed size button");
b1.setSize(400, 400);
c1.setContent(b1);
shell.addControlListener( new ControlAdapter() {
@Override
public void controlResized( ControlEvent e ) {
ScrollBar sbX = c1.getHorizontalBar();
if ( sbX != null ) {
sbX.setPageIncrement( sbX.getThumb() );
sbX.setIncrement( Math.max( 1, sbX.getThumb() / 5 ) );
}
}
});
shell.setSize(600, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Thanks... Dominik.
|
|
|
Re: ScrolledComposite scrolling in tiny steps if I click in the scroll bar [message #522479 is a reply to message #521960] |
Mon, 22 March 2010 13:28 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
It looks like the ControlListener being added should be more like the
following (?):
c1.addControlListener( new ControlAdapter() {
public void controlResized( ControlEvent e ) {
ScrollBar sbY = c1.getVerticalBar();
if ( sbY != null ) {
sbY.setPageIncrement(c1.getSize().y);
}
}
});
HTH,
Grant
"Dominik Stadler" <dominik.stadler@gmx.at> wrote in message
news:hnvtl1$vrf$1@build.eclipse.org...
> Hi,
>
> I am trying to use ScrolledComposite with SWT/Eclipse 3.5.2 and was trying
out the snippets at http://www.eclipse.org/swt/snippets/#scrolledcomposite
>
> What I found is that each of the snippets shows a strange scrolling
behavior. If I click into the scrollbar region, I usually expect the area to
scroll by one page. However what happens with ScrolledComposite is that it
only scrolls a bit, much less than a page.
>
> I found Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=39934 which
handles this problem, but there no progress since 2004.
>
> I also found
http://stackoverflow.com/questions/858591/how-do-you-change- a-scrolledcomposites-horizontal-scroll-increment,
which proposes a workaround, however this does not work for me.
>
> What do I need to make this work?
>
>
> import org.eclipse.swt.*;
> import org.eclipse.swt.widgets.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.custom.*;
> import org.eclipse.swt.events.ControlAdapter;
> import org.eclipse.swt.events.ControlEvent;
>
> public class Snippet5_WithPageScroll {
>
> public static void main (String [] args)
> {
> Display display = new Display ();
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
>
> // this button is always 400 x 400. Scrollbars appear if the window is
resized to be
> // too small to show part of the button
> final ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER |
SWT.H_SCROLL | SWT.V_SCROLL);
> Button b1 = new Button(c1, SWT.PUSH);
> b1.setText("fixed size button");
> b1.setSize(400, 400);
> c1.setContent(b1);
>
> shell.addControlListener( new ControlAdapter() {
> @Override
> public void controlResized( ControlEvent e ) {
> ScrollBar sbX = c1.getHorizontalBar();
> if ( sbX != null ) {
> sbX.setPageIncrement( sbX.getThumb() );
> sbX.setIncrement( Math.max( 1, sbX.getThumb() / 5 ) );
> }
> }
> });
>
> shell.setSize(600, 300);
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
> }
>
>
> Thanks... Dominik.
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03348 seconds