Bug or feature? setProps when replacing whole propertySet

Richard Gaskin ambassador at fourthworld.com
Thu Feb 12 14:42:38 EST 2009


I have an app in which I'm using setProp handlers for preferences values.

I'm now adding a "Reset Defaults" feature, and figured it'd be pretty 
convenient for me to just swap out the whole set of values in the prefs 
property set with a matching default set, a la:

   set the customProperties[uPrefs] of stack "4wTextEdit" \
     to the customProperties[uPrefsDefaults] of stack "4wTextEdit"

What I discovered is that when you replace a whole set of properties en 
masse like this, the setProp handler for the affected property set 
doesn't trigger.

It'd be darned convenient if it did, but perhaps there's some reason why 
it shouldn't.

Is this a bug or a feature?



As a workaround I wrote a generic handler for triggering setProp 
messages for any property set of any object:


on TicklePropSet pPropSet, pObj
   put the customProperties[pPropSet] of pObj into tPropsA
   repeat for each key tLabel in tPropsA
     do "set the "& pPropset &"[tLabel] of pObj to tPropsA[tLabel]"
    -- set the pPropset[tLabel] of pObj to tPropsA[tLabel]
   end repeat
end TicklePropSet


Oddly enough, the comment line doesn't work and doesn't throw an error 
either (another thing that might be handy, using variables as the names 
of property sets).

--
  Richard Gaskin
  Fourth World
  Revolution training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com



More information about the use-livecode mailing list