I should know better by now to never declare victory until you tried your
test app solution in your REAL app.

A problem occured that if your popupbutton is embedded in another control,
the "y" value will no longer be in the same frame of reference as the popup,
which is no a child of the same control as the popupbutton.  So this may not
be the BEST way to do it, but it works:

gr.validateSize(true);
var verticalGap:Number = grid.getStyle("verticalGap");
grid.scrollRect = new Rectangle(0, 0, grid.width + gr.measuredWidth,
    grid.height + gr.measuredHeight + (isNaN(verticalGap) ? 0 :
verticalGap));
if (grid.localToGlobal(new Point(0, 0)).y < grid.owner.localToGlobal(new
Point(0, 0)).y)
  grid.y -= gr.measuredHeight + (isNaN(verticalGap) ? 0 : verticalGap);


On Tue, Jun 16, 2009 at 10:38 AM, Pan Troglodytes <chimpathe...@gmail.com>wrote:

> C'mon, Tim, your posts help me loads of times and you don't even realize
> it.  My #1 place to go for searching for answers to tough problems is my
> flexcoders archive and your name pops up a lot with the answer!  And
> RowColorDataGrid was a lifesaver.
>
>
> Okay, back to the topic.  Just realized that there's a little something
> missing.  If you have the popupButton on the bottom of the window so that it
> causes the popup to appear ABOVE it, then the code above glitches in that it
> makes the window grow down and cover the popupbutton.  Here's a fix:
>
> gr.validateSize(true);
> var verticalGap:Number = grid.getStyle("verticalGap");
> grid.scrollRect = new Rectangle(0, 0, grid.width + gr.measuredWidth,
>     grid.height + gr.measuredHeight + (isNaN(verticalGap) ? 0 :
> verticalGap));
> if (grid.y < myPopupButton.y)
>   grid.y -= gr.measuredHeight + (isNaN(verticalGap) ? 0 : verticalGap);
>
> To see this in action in the above example, set the application
> layout="absolute" and the myPopupButton bottom="0".
>
> Of course, when you add so many categories that it gets taller than the
> window its in, then you're screwed!  You'd have to implement your own "don't
> grow when bigger than this and turn on scrollbars instead" logic.  Luckily I
> don't need that right now.
>
>
> On Tue, Jun 16, 2009 at 10:20 AM, Tim Hoff <timh...@aol.com> wrote:
>
>>
>>
>>
>> Yep, that looks great. I thought about all of that, but knew that you'd
>> tweak it to get what you needed. Glad that I could finally help you out
>> with something Jason.
>>
>>
>> -TH
>>
>> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, Pan
>> Troglodytes <chimpathe...@...>
>> wrote:
>> >
>> > Thanks, Tim. Knew there must be something, just couldn't find it.
>> >
>> > I found this to be a good way to do it, as long as I'm not missing
>> > something:
>> >
>> > gr.validateSize(true);
>> > var verticalGap:Number = grid.getStyle("verticalGap");
>> > grid.scrollRect = new Rectangle(0, 0, grid.width + gr.measuredWidth,
>> > grid.height + gr.measuredHeight + (isNaN(verticalGap) ? 0 :
>> > verticalGap));
>> >
>> > This seems more "right", though if you add some big numbers to height
>> and
>> > width it will always auto-calc them. But I found if you add numbers
>> that
>> > are too small, you wind up with it chopped off a bit.
>> >
>> > On Mon, Jun 15, 2009 at 10:08 PM, Tim Hoff timh...@... wrote:
>> >
>> > >
>> > >
>> > > Hi Jason,
>> > >
>> > > Put this at the end of addCategory():
>> > >
>> > > myPopupButton.popUp.scrollRect =
>> > > *new* Rectangle(0, 0, myPopupButton.popUp.width,
>> > > myPopupButton.popUp.height + 30);
>> > >
>> > > Add an id:
>> > >
>> > > <PopUpButton id="myPopupButton" openAlways="true">
>> > >
>> > > This will trick the popup into redrawing.
>> > >
>> > > -TH
>> > >
>> > >
>> > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, Pan
>> Troglodytes chimpathetic@
>> > > wrote:
>> > > >
>> > > > Okay, so given the following application:
>> > > >
>> > > > <?xml version="1.0" encoding="utf-8"?>
>> > > > <Application
>> > > > xmlns="http://www.adobe.com/2006/mxml";
>> > > > >
>> > > > <Script>
>> > > > <![CDATA[
>> > > > private function addCategory():void
>> > > > {
>> > > > var gi:GridItem;
>> > > > var gr:GridRow = new GridRow;
>> > > >
>> > > > gi = new GridItem;
>> > > > (gi.addChild(new Label) as Label).text = "item " +
>> (grid.numChildren
>> > > > - 3) + ":";
>> > > > gr.addChild(gi);
>> > > >
>> > > > gi = new GridItem;
>> > > > (gi.addChild(new Label) as Label).text = "value";
>> > > > gr.addChild(gi);
>> > > >
>> > > > grid.addChildAt(gr, grid.numChildren - 2);
>> > > > }
>> > > > ]]>
>> > > > </Script>
>> > > > <PopUpButton openAlways="true">
>> > > > <popUp>
>> > > > <Grid id="grid" paddingTop="4" paddingBottom="4" paddingLeft="4"
>> > > > paddingRight="4"
>> > > > fontSize="12" backgroundColor="0xFFFFFF" borderStyle="outset"
>> > > > borderThickness="2"
>> > > > >
>> > > > <GridRow>
>> > > > <GridItem colSpan="3">
>> > > > <CheckBox label="Categorize data" fontWeight="bold"/>
>> > > > </GridItem>
>> > > > </GridRow>
>> > > > <GridRow>
>> > > > <GridItem>
>> > > > <Label text="Start:"/>
>> > > > </GridItem>
>> > > > <GridItem>
>> > > > <Label text="first row"/>
>> > > > </GridItem>
>> > > > </GridRow>
>> > > > <GridRow id="lastRow">
>> > > > <GridItem>
>> > > > <Label text="End:"/>
>> > > > </GridItem>
>> > > > <GridItem>
>> > > > <Label text="last row"/>
>> > > > </GridItem>
>> > > > </GridRow>
>> > > > <GridRow>
>> > > > <GridItem colSpan="3">
>> > > > <Button label="Add Category" click="addCategory()"/>
>> > > > </GridItem>
>> > > > </GridRow>
>> > > > </Grid>
>> > > > </popUp>
>> > > > </PopUpButton>
>> > > > </Application>
>> > > >
>> > > > I want to be able to click the popupButton, click the "Add
>> Category"
>> > > button,
>> > > > and have the popped up window resize right then so you can see
>> > > everything.
>> > > > Is there a good way (or even an ok way) to do this?
>> > > >
>> > > > --
>> > > > Jason
>> > > >
>> > >
>> > >
>> >
>> >
>> >
>> > --
>> > Jason
>> >
>>
>>  
>>
>
>
>
> --
> Jason
>



-- 
Jason

Reply via email to