| Summary: | [ScrolledComposite] ScrollBar#setSelection doesn't work anymore | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Arian Storch <storch> |
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | ivan |
| Version: | 1.5 | ||
| Target Milestone: | 1.5 M7 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Arian Storch
Arian, just checked your snippet against SWT and the ScrolledComposite content location (ScrolledComposite vertical scrollbar position) is not set if you call ScrollBar#setSelection. Just add a sysout after vBar.setSelection( 100 ); to get the selection and you will get 0: .. vBar.setSelection( 100 ); System.out.println( cmp.getLocation() ); System.out.println( vBar.getSelection() ); .. Even if it worked before I think that the bug is invalid. Please reopen if you disagree. Just a note: If you want to scroll the ScrolledComposite programmatically use ScrolledComposite#setOrigin. Hi Ivan,
thanks for your investigation!
For RAP ScrolledComposite#setOrigin is working. But for "native" SWT ScrollBar#setSelection works too.
On a native platform both leads to nearly the same behavior. I've just tested it with Eclipse Version 3.7.0. Unfortunately the behavior for RAP isn't the same. As described above ScrollBar#setSelection doesn't work anymore.
Note: My first code snipped included an error. So I'm posting my test code again (for native SWT):
--
ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
Composite cmp = new Composite(sc, SWT.BORDER);
cmp.setLayout(new GridLayout( 1, false));
Label lbl = new Label(cmp, SWT.NONE);
lbl.setBackground(new Color(Display.getCurrent(), 0, 255, 0));
lbl.setText("XXX");
cmp.setSize(1600, 2400);
sc.setContent(cmp);
sc.setMinSize(1024,978);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setAlwaysShowScrollBars(true);
ScrollBar vBar = sc.getVerticalBar();
ScrollBar hBar = sc.getHorizontalBar();
//sc.setOrigin(100,100); //WORKS
vBar.setSelection(100); //BUT THIS ALSO
hBar.setSelection(100);
I've just tested my snipped against RAP 1.4. Here it works fine and as expected! Fixed in ScrolledCompositeLCA by getting the origin form the scrollbars selection (as it was in v1.4). |