pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Allman <...@allman.ms>
Subject Re: setting properties on includes
Date Thu, 01 Jul 2010 23:26:28 GMT
Sure.  Here's a totally contrived example, but it illustrates a simple use 
case---setting the size of an included component.

Suppose my_box.wtkx is

<BoxPane xmlns="org.apache.pivot.wtk">
 	<Label text="Hey!" />
</BoxPane>

Suppose main_window.wtkx is

<Frame xmlns="org.apache.pivot.wtk" xmlns:wtkx="http://pivot.apache.org/wtkx">
 	<content>
 		<BoxPane orientation="vertical">
 			<wtkx:include wtkx:id="box1" src="my_box.wtkx" />
 			<wtkx:include wtkx:id="box2" src="my_box.wtkx" />
 		</BoxPane>
 	</content>
</Frame>

I want box1 to have a preferred height of 20 and box2 to have a preferred 
height of 50.  Make sense?

Michael

On Thu, 1 Jul 2010, Greg Brown wrote:

> That's right. We support static setters (attached properties) on 
> includes because you don't necessarily know what container the included 
> component might be placed in. But we don't support instance setters 
> because we assume that you will simply set them within the include 
> itself.
>
> It is possible to change this behavior such that instance setters are 
> supported on an include - but is there any reason you can't put the 
> attributes on the root element of the include instead?
>
> Greg
>
> On Jul 1, 2010, at 5:47 PM, Michael Allman wrote:
>
>> Oh, yeah.  I got confused with width and height.  It's a flex thing.
>>
>> So I just tried
>>
>> <wtkx:include src="whatever.wtkx" preferredWidth="100" preferredHeight="100"/>
>>
>> and that doesn't work either.  I get a message saying "Instance property setters
are not supported for wtkx:include tag."
>>
>> What do you think?
>>
>> Cheers,
>>
>> Michael
>>
>> On Thu, 1 Jul 2010, Greg Brown wrote:
>>
>>> Setting properties on an include should work fine. However, if you want to specify
the size of a component, you should generally use preferredWidth and preferredHeight rather
than width and height. It is up to the container to determine if/how the preferred values
should be applied.
>>>
>>> On Jul 1, 2010, at 8:53 AM, Michael Allman wrote:
>>>
>>>> Hi,
>>>>
>>>> I'd like to set some properties on the root element of an included wtkx.
A classic case is setting width and height.  How might I go about doing this?
>>>>
>>>> <wtkx:include src="whatever.wtkx" width="100" height="100"/>
>>>>
>>>> does not work.
>>>>
>>>> Cheers,
>>>>
>>>> Michael
>>>>
>>>
>

Mime
View raw message