[Laszlo-dev] [Platform-team] lz.colors question

P T Withington ptw at pobox.com
Fri Nov 14 10:55:52 PST 2008


But he should also be able to say:

   bgcolor="iceblue"

and/or

   bgcolor="${this.acceptValue('iceblue', 'color')}"

Which might be more instructive.  In the first case, you are  
specifying a constant color, and since bgcolor is an attribute with a  
type of `color` the token `iceblue` is acceptable as a value (not  
tested).  In the second case, you are using a constraint, and (at  
least as of now), constraints are simply expressions that _directly_  
set the value of an attribute -- they _do_not_ pass through the data  
interface, which converts string representations into values according  
to type.  (I think this is desirable.)  So, in the second case, I am  
calling the (currently unpublished) `acceptValue` method, which takes  
a string representation of a value and parses it according to the  
specified type.

There should be a better way.  Perhaps I should be able to say:

   bgcolor="$accept{'iceblue'}"

(meaning use acceptValue and the attribute's declared type to parse  
the value of the expression)?  We've already got $path and $style, why  
not $accept (unless someone can come up with a better name).  I think  
this would allow me to say something like:

   <inputtext id="color" />
   <view bgcolor="$accept{color.text}" />

would that be useful?


On 2008-11-13, at 21:16EST, Max Carlson wrote:

> You should be able to just set it to bgcolor="lz.colors.iceblue4" -  
> constraints shouldn't be required.  Also note that colors aren't in  
> global[] anymore - use lz.colors[''] instead.
>
> J Crowley wrote:
>> So, I'm working on fixing one of the color dguide examples.  The  
>> description on the doc page (docs/developers/color.html) reads:
>> -----
>> To specify any color but the 16 which are usable by name, use  
>> 0xFFFFFF hex codes. Alternatively, the non-standard colors named in  
>> |lps/components/base/colors.lzx| were added to OpenLaszlo's global  
>> namespace. Those colors can also be employed by name, but note the $ 
>> {constraint} syntax around the bgcolor specification. There are two  
>> ways to make the constraint: |bgcolor="${global['iceblue1']}"| is  
>> the same as |bgcolor="${iceblue1}"|.
>> -----
>> The example this describes is:
>> -----
>> <canvas debug="true">
>> <simplelayout axis="x" spacing="10"/>
>> <class name="box1" width="100" height="100" bgcolor="$ 
>> {global['gold4']}" />
>> <class name="box2" width="100" height="100" bgcolor="${iceblue1}" />
>> <box1 id="sun">
>>   <text text="Sun"/>
>> </box1>
>> <box2 id="mystic">
>>   <text fgcolor="0xFFFFFF" text="Mystic"/>
>> </box2>
>>  </canvas>
>> -----
>> Thing is, the only way to get the example to work is to change  
>> bgcolor="${iceblue1}" to bgcolor="${lz.colors.iceblue1}", and  
>> trying to use the global['gold4'] syntax doesn't actually work.  So  
>> my question is:  Is the description in the documentation wrong?   
>> Because doing it the way the description states results in a  
>> Debugger error.  (Keep in mind I'm using the docs on  
>> openlaszlo.org, since I can't build locally, so if the description  
>> has already been changed, let me know and I won't file the bug, but  
>> I do need to fix the example.  What I need to know then is, what is  
>> the new way of doing this?)
>> Thanks!
>> Josh
>
> -- 
> Regards,
> Max Carlson
> OpenLaszlo.org



More information about the Laszlo-dev mailing list