Skip navigation
Currently Being Moderated

Help with creating a component: auto-sizing

Jan 7, 2014 9:19 AM

I'm trying to create a lightweight component (extends UIComponent) that supports auto-sizing (aka default sizing.) Many of the Flex component's do this, for instance mx:Button will, if you do not set a size, size itself to be "large enough to hold the label text, and any icon." How can I do this with my component?

 

I tried overriding measure() and setting the measured sizes (measuredWidth, measuredHeight, measuredMinWidth, measuredMinHeight) but updateDisplayList always gets called with values of 0, 0 for unscaledWidth and unscaledHeight, and the .width and .height properties always stay at 0, 0.

 

I've looked over the mx:Button code quite a bit and cannot figure out how it manages to perform default/auto-sizing. Can anyone help?

 

Cheers.

-Aaron

 
Replies
  • Currently Being Moderated
    Jan 7, 2014 8:19 PM   in reply to Aaron Beall

    Is measure() being called?  If explicitWidth/Height get set somehow (like to 0), then measure won't get called and you'll get sized at 0x0

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 9, 2014 8:28 PM   in reply to Aaron Beall

    You could set breakpoints to see if explicitWidth/Height is getting set in some surprising way.  Could maxWidth/maxHeight be set to 0?  That could also mess it up.

     

    One more thing is that the component is given its size by its parent.  If the parent is 0x0 that could also cause trouble.  Or some other part of the layout logic is trumping the measuredWidth/Height.  In theory there should be a call to setActualSize or setLayoutBoundsSize.  A breakpoint there should help you figure out the logic that determined the size.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points