Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you refer to as "pass-through" styles are actually called inheriting styles. The solution to your question is in fact quite simple.</p> <p>You use the <a href="http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf680e1-7ffe.html#WS2db454920e96a9e51e63e3d11c0bf69084-7a1a" rel="nofollow">style metadata</a> on your custom component to declare that ButtonPanel has a stylename called 'buttonStyleName':</p> <pre><code>[Style(name="buttonStyleName", inherit="yes")] public class ButtonPanel extends Panel { .... } </code></pre> <p>Note the 'inherit' flag which is set to true: this will make sure that any component inside your custom Panel that has the same style will inherit the value that you've given to that style at the Panel level.</p> <p>Setting this metadata will make sure that FlashBuilder will suggest buttonStyleName as a style and not as a property (as would happen with Sam's solution).</p> <hr> <p><strong>Edit</strong>: already defined styles</p> <p>I didn't realize at first that you were referring to the mx ButtonBar (as it's not explicitly mentioned). The reason this is not working for you is that mx:ButtonBar already has these styles defined as not inheriting. Look at the source code:</p> <pre><code>[Style(name="firstButtonStyleName", type="String", inherit="no")] [Style(name="buttonStyleName", type="String", inherit="no")] [Style(name="lastButtonStyleName", type="String", inherit="no")] </code></pre> <p>Because of this the compiler will complain when you try to override that definition in your custom Panel, because it simply wouldn't know which of the contradictory instructions to pick. So we'll have to do a little more work if you want to stick with mx:ButtonBar.</p> <p>First define the styles on ButtonPanel exactly as they are defined in mx:ButtonBar so they have the same signature (you can just copy/paste the three lines above). This will shut up the compiler but the styles won't be inherited anymore, right?</p> <p>So we'll have to pass them on manually: in your custom Panel skin, override the <code>updateDisplayList()</code> method and - assuming that the ButtonBar's id is 'buttonBar' - add the following:</p> <pre><code> private const buttonStyles:Array = [ "firstButtonStyleName", "buttonStyleName", "lastButtonStyleName" ]; override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (buttonBar) for each (var buttonStyle:String in buttonStyles) buttonBar.setStyle(buttonStyle, getStyle(buttonStyle)); //some other code super.updateDisplayList(unscaledWidth, unscaledHeight); } </code></pre> <p>This will take the styles from the host Panel and pass them on to the ButtonBar.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload