Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » ScrolledComposite does not work properly unless you explicitly set the size of the scrolled content
ScrolledComposite does not work properly unless you explicitly set the size of the scrolled content [message #1414843] Mon, 01 September 2014 12:18 Go to next message
Tomas Normark is currently offline Tomas NormarkFriend
Messages: 8
Registered: September 2010
Junior Member
Paste the code at the end of this message into the createContents method of a class that extends AbstractEntryPoint (which means that parent in the code below is the top level parent passed into the startup of a RAP application). No vertical scroller appears unless you uncomment the line that explicitly sets the size of the scrolled content. This means that the content is just cut off at the end of the height of the browser window. This is not necessary when running the corresponding code with SWT.

How is this supposed to work? You cannot really know the size needed for the child content. Is there some method that can be run to dynamically determine this size at runtime or is there some other way this is supposed to be handled?

Best regards,

Tomas Normark


GridLayout layout = new GridLayout(1, false);
parent.setLayout(layout);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = GridData.FILL;
ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
sc.setLayoutData(gridData);
Composite child = new Composite(sc, SWT.NONE);
GridLayout childLayout = new GridLayout(2, false);
child.setLayout(childLayout);
for (int i=0; i<40; i++) {
Label label = new Label(child, SWT.NONE);
label.setText("Row " + (i+1) + ":");
Text text = new Text(child, SWT.BORDER);
}
// child.setSize(800, 1500);
sc.setContent(child);
Re: ScrolledComposite does not work properly unless you explicitly set the size of the scrolled cont [message #1414846 is a reply to message #1414843] Mon, 01 September 2014 12:24 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2334
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Tomas,
did you check your snippet against SWT? Does it work there?
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: ScrolledComposite does not work properly unless you explicitly set the size of the scrolled cont [message #1415239 is a reply to message #1414846] Tue, 02 September 2014 11:47 Go to previous messageGo to next message
Tomas Normark is currently offline Tomas NormarkFriend
Messages: 8
Registered: September 2010
Junior Member
Ivan Furnadjiev wrote on Mon, 01 September 2014 08:24
Hi Tomas,
did you check your snippet against SWT? Does it work there?
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/


Hi Ivan,

I can get this to work similarly in SWT and RAP by adding a line

child.setSize(child.computeSize(SWT.DEFAULT, SWT.DEFAULT));

instead of the line with a hard coded size that I had commented out in my example. For the SWT case this works perfectly. However for the RAP case the size is underestimated in this case and even though I get a vertical scrollbar I only see 36 of the 40 rows of labels and input fields in the example and the right part of the input fields on each row is cutoff.

Can you recommend a way of getting a proper size calculation also for the RAP case?

Best regards,

Tomas Normark
Re: ScrolledComposite does not work properly unless you explicitly set the size of the scrolled cont [message #1415257 is a reply to message #1415239] Tue, 02 September 2014 12:26 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2334
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Tomas,
the proper usage of ScrolledComposite is shown in SWT Snippets [1]. I
think you have to specify the minSize of the scrolled composite. About
the cut-off content issue - we already have a bug about it:
414868: [ScrolledComposite] Content is cut off to the right
https://bugs.eclipse.org/bugs/show_bug.cgi?id=414868

To workaround it, you have to do layout/setMinSize twice.

[1] https://www.eclipse.org/swt/snippets/
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:RichTextViewer - Modify Listener
Next Topic:Nebula grid repo RAP 2.3 requires RAP 3.0
Goto Forum:
  


Current Time: Thu Feb 20 10:22:33 GMT 2020

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

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

Back to the top