[General] Why doesn't an 'accept changes' on border colour affect the colour?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[General] Why doesn't an 'accept changes' on border colour affect the colour?

Andy Burnett
Changing e.g. fishEye to true, changes the object behaviour. However,
setting the rgb() value to something new has no effect. How come?

Cheers
AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://livelykernel.sunlabs.com/pipermail/general/attachments/20080322/2e802cc8/attachment.html 


Reply | Threaded
Open this post in threaded view
|

[General] Why doesn't an 'accept changes' on border colour affect the colour?

Dan Ingalls-3
Andy Burnett  asked...

>Changing e.g. fishEye to true, changes the object behaviour. However, setting the rgb() value to something new has no effect. How come?

Hello, Andy -

There is no general dependence mechanism in JavaScript so that changes to values get magically acted on.  It happens that the fisheye mechanism tests the fishEye property in such a way that only setting the flag is necessary.

However if you want a morph's color to change, you should use the setFill() method.  This will take care of the necessary and appropriate propagation of change so that the SVG graphic routines get appropriately informed.

In general we favor a procedural interface for such changes.  We have toggleFisheye(), but should probably also have setFisheye(trueOrFalse).

Hope this helps

        - Dan


Reply | Threaded
Open this post in threaded view
|

[General] Why doesn't an 'accept changes' on border colour affect the colour?

Dan Ingalls-3
>
>Thanks Dan
>
>Unfortunately, I am still not quite getting this.  Based upon what you wrote, I understand the inspector reports the current property values for the instance. I can edit the properties, but they don't have any impact unless and until the object checks its own properties - presumably as a result of some event such as onMouseOver.  That all makes sense.
>
>However, what I am not getting is where to execute the setFill() code. I tried entering setFill(255,0,0) as the new value for fill in the inspector (top right pane) and both accepting the change and executing javascript.  I then tried the same thing in the bottom 'code' pane.  I also tried self.SetFill()  (old habits die hard ;-)
>
>None of these worked, so I am obviously missing the obvious.  Could you enlighten me please

No problem.  In the absence of adequate documentation (to which we readily confess) your best bet is to search the code base.  There you will discover, either through usage or comments in the code, that setFill expects its argument to be a Color or a Gradient (Linear or Radial).

I believe the correct way to write your example is

        this.setFill(new Color(1, 0, 0));  // We use 0..1 instead of 0..255.

Hope this helps.  I've CC'd the list in case this kind of info may be useful to others.

        - Dan
---------------------------------------

>On 24 Mar 2008,@13:26, Dan Ingalls wrote:
>
>>Andy Burnett  asked...
>>
>>>Changing e.g. fishEye to true, changes the object behaviour. However, setting the rgb() value to something new has no effect. How come?
>>
>>Hello, Andy -
>>
>>There is no general dependence mechanism in JavaScript so that changes to values get magically acted on.  It happens that the fisheye mechanism tests the fishEye property in such a way that only setting the flag is necessary.
>>
>>However if you want a morph's color to change, you should use the setFill() method.  This will take care of the necessary and appropriate propagation of change so that the SVG graphic routines get appropriately informed.
>>
>>In general we favor a procedural interface for such changes.  We have toggleFisheye(), but should probably also have setFisheye(trueOrFalse).
>>
>>Hope this helps
>>
>> - Dan