PDA

View Full Version : Simple Panel Scrolling Question


Mortimer Jazz
02-02-2007, 08:03 AM
Hi, this has to be easy but I cant see it for searching!

I have a Panel.
Inside it is a Text component displaying some dynamic text, and a Repeater underneath that (repeating a CheckBox with dynamically populated labels) .

I want to set the "maxHeight" of the Panel (so that if I get too many Checkboxes appearing, my content will scroll vertically).

When the vertical scrollbar appears, so does the horizontal scrollbar ...this is because the width of my Panel doesn't change, but the vertical scrollbar eats in to that width - therefore I get horizontal scrolling of about 16 pixels.

If I set horizontalScrollbarPolicy to false then my content is still clipped by the vertical scrollbar.
note: My Panel doesn't have a width specified. I have tried setting the width of it and all children to 100% - I still get clipping.

A workaround is easy enough (listen for a scroll event and add/subtract 16 pixels from the width for example), but I thought there must surely be something in-built, already in place to deal with this kind of scenario, as it must be such a common one.
To sum up ... when a vertical scrollbar appears, I want the content inside the panel should resize rather than have a horizontal scrollbar appear.

Help much appreciated. I can post the code if need be.
Cheers.

Tink
02-02-2007, 10:21 AM
You'll need to listen for when the last item is created, catch that event, then check the size , or if the Panal has a VerticalScrollBar. If it does the change the width of the content.

You might require 'callLater()'.

I put in a request the other week for events to be added when scrollbars are added and removed.

Mortimer Jazz
02-02-2007, 11:39 AM
Thanks Tink. Glad to have it cleared up

Good request.

Tink
02-02-2007, 11:57 AM
Yeah the thing is that ScrollBars always appear inside a container. This is standard practice as you would want to set something to a width of 100, to find when a ScrollBar is added its then 120.

It would be a lot easier if they add those events, as at the mo there seems to be a frame delay etc until the scrollbar properties are change from null to having a value.