setprop handlers for custom property sets
Peter M. Brigham
pmbrig at gmail.com
Fri Jul 31 08:38:42 EDT 2015
On Jul 30, 2015, at 4:34 PM, Mark Wieder wrote:
> Paul Dupuis <paul at ...> writes:
>
>>
>> The LC 6.7.5 dictionary entry for setProp has the following:
>>
>> If the custom property you want to control is in a custom property set,
>> use array notation in the first line of the setProp handler, as in the
>> following example:
>
> Interesting. I do see that in the documentation, but I've never used that.
> The way I've always dealt with custom property sets is to switch context:
>
> set the customPropertySet of <object> to <name>
> set the <property> of <object> to <whatever>
> get the <property> of <object>
> set the customPropertySet of <object> to empty
>
> I think this makes for a cleaner, easier-to-read format anyway.
I use these, an easy and modular approach:
on setCustomProp pObjRef, pPropSet, pProp, pValue
-- modeled after deleteCustomProp
-- not sure where this comes from
put the custompropertyset of pObjRef into oldPropSet
set the custompropertyset of pObjRef to pPropSet
set the pProp of pObjRef to pValue
set the custompropertyset of pObjRef to oldPropSet
end setCustomProp
function getCustomProp pObjRef, pProp, pPropSet
-- modeled after deleteCustomProp
-- not sure where this comes from
-- if pPropSet = empty then uses the default custompropertyset
put the custompropertyset of pObjRef into oldPropSet
set the custompropertyset of pObjRef to pPropSet
put the pProp of pObjRef into tValue
set the custompropertyset of pObjRef to oldPropSet
return tValue
end getCustomProp
on deleteCustomProp pObjRef, pProp, pPropSet
-- not sure where this comes from, it's not mine
-- thanks to <whoever> !
put the custompropertyset of pObjRef into oldPropSet
set the custompropertyset of pObjRef to pPropSet
put the customkeys of pObjRef into keysList
set the wholematches to true
put lineoffset(pProp,keysList) into propLine
if propLine <> 0 then
delete line propLine of keysList
set the customkeys of pObjRef to keysList
end if
set the custompropertyset of pObjRef to oldPropSet
end deleteCustomProp
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
More information about the use-livecode
mailing list