Inheritance and Custom Properties

Jim Bufalini jim at
Thu Apr 16 19:36:36 EDT 2009

Hi David,

>  Agreed it is not real OOP inheritance. But just in case you don't get
> the
> way you use "getprop/setprop" handlers to achieve the same sort of
> automatic
> creation of properties that you refer to I'll give you few examples:

Actually, the lights went on as soon as you first said it. :-) We've used
get/setProp for quite a while, but at a more "local" level. For example, if
you have downloaded the free ListMagic trial and create a list widget on a
card, you will find a fairly large setProp in the field script of the widget
with a switch statement that governs what happens when a custom property for
that field changes. The matching getProp is in the ListMagic lib. But,
honestly, I never thought of using this method to fake inheritance until you
said it. ;-)
>    1. You want to create a form view, in which you place records, and
> you
>    want these records to automatically inherit certain properties
> relating to
>    forms - as a simple example you want each control to automatically
> have a
>    property "record_Value". Solution add getprop/setprops to the stack
> script
>    which check for the type of controla nad return and appropriate
> value - all
>    controls in the stack inherit this property without you having to do
>    anything.
>    2. You want to create a series of image controls that all inherit
> some
>    basic class of properties relevant to images that are not built in
> to the
>    engine. Old technique create a library that implements these
> properties for
>    any images that has some custom property - say "uImageClass" set to
> true or
>    some specific "class" name. New technique implement a behavior and
> add the
>    library scripts to the behavior - except you don't need to check for
> a
>    custom property - instead you can define a single geptprop/setprop
> in a
>    library - say "setprop image_Class someBoolean" which sets the
> behavior of
>    the target image.
> In all these cases the inherited behavior is automatic in the sense you
> describe - you just issue one command to add the inherited behavior to
> a
> control.

Can you be more specific about this one command that kicks off the whole
shebang? Are you using the newButton, newStack, etc. messages that then do
an arbitrary getProp which triggers a sequence of copying the custom
properties? Or is it simpler than that? Thanks!

Aloha from Hawaii,

Jim Bufalini

More information about the use-livecode mailing list