The problem is actually when the descendant gets added, not the style class. In 
the example below, the PushButton is added to the BoxPane before the 
"styleClass" attribute is set, but the BoxPane has not yet been added to the 
Window (because its end tag has not yet been processed). As a result, a 
getNamedStyle() method that walks up the tree looking for inherited styles 
would return null when passed an argument of "foo".

I think the include approach will work well. I'm pretty close to done with it - 
will hopefully check it in later this morning.

On Jul 5, 2010, at 3:20 AM, Noel Grandin wrote:

> As a compromise, how about we allow the following syntax:
> 
> <Window>
>  <StyleClass name="foo">{...}</StyleClass>
>  <BoxPane>
>    <PushButton styleClass="foo"/>
>  </BoxPane>
> </Window>
> 
> 
> Or some other variant, where the essential point is that it style classes get 
> declared as one of the first child
> elements on a container, so that it gets added to the parent early.
> 
> -- Noel Grandin
> 
> Greg Brown wrote:
>> FYI, named styles are turning out to be a lot more challenging than I 
>> expected. The solution I proposed the other day doesn't work - elements in 
>> BXML aren't added to the parent element until the end tag is processed. So, 
>> given the following structure:
>> 
>> <Window styleClasses="{foo:{...}}">
>>  <BoxPane>
>>    <PushButton styleClass="foo"/>
>>  </BoxPane>
>> </Window>
>> 
>> when the styleClass attribute of the PushButton is processed, the BoxPane 
>> hasn't yet been added to the Window, so the "foo" style class name resolves 
>> to null.  :-(
>> 
>> I'll keep thinking about it, though. Suggestions are welcome.
>> 
>> Thanks,
>> G
>> 
> 

Reply via email to