forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbehavior.xml
More file actions
77 lines (62 loc) · 4.05 KB
/
Copy pathbehavior.xml
File metadata and controls
77 lines (62 loc) · 4.05 KB
1
<doc> <legacy_id>3514</legacy_id> <name>behavior</name> <type>property</type> <syntax> <example>set the behavior of <i>childObject</i> to <i>behaviorObjectReference</i></example> </syntax> <synonyms> <synonym>parentScript</synonym> </synonyms> <summary>Specifies where an object used as a custom control should inherit its behavior from.</summary> <examples><example>set the behavior of tNewGroup to the long id of button "Widget" of card "Behaviors"</example> </examples> <history> <introduced version="3.5">Added.</introduced> <deprecated version=""></deprecated> <removed version=""></removed> <changed version="6.1">Chained behaviors</changed> <experimental version=""></experimental> <nonexperimental version=""></nonexperimental> </history> <objects> <stack/> <card/> <group/> <field/> <button/> <graphic/> <scrollbar/> <player/> <image/> </objects> <platforms> <mac/> <windows/> <linux/> <ios/> <android/> </platforms> <classes> <desktop/> <server/> <web/> <mobile/> </classes> <security> </security> <classification> <category>Writing LiveCode</category> </classification> <references> <command tag="dispatch">dispatch Command</command> </references> <description> <overview>Behaviors are a method to create common functionality between objects without duplicating the scripts.</overview> <parameters> </parameters> <value>The <b>behavior</b> property is a reference to a button containing the script to use. The format stored in the object it's assigned to is similar to a long ID, except that a long ID includes the full path to the stack file and the form stored in the behavior includes only the stack name, allowing the reference to continue to work after the stack file has been moved to another computer.<p></p><p>When setting the value of the <b>behavior</b> property to a long ID, LiveCode converts it to a rugged form without the stack file path.</p><p></p><p>By default, the <b>behavior</b> of newly created objects is empty.</p></value> <comments>An object with a <b>behavior</b> set will act as though its script was set to the script of the <b>behavior</b> button. If multiple objects share the same <b>behavior</b>, each will have its own set of script local variables. Any references to me, the owner of me etc will resolve to the child object currently executing.<p></p><p>The button containing the behavior script can be located anywhere. In particular this allows for it be located in a password protected stack, allowing you to protect the script without need to protect the controls using it.</p><p></p><p>Behaviors are resolved by LiveCode immediately after loading a stack file, the engine acts as though it is resolving a control reference of the form: button id <id> of stack <stack name> [ of stack <mainstack name>]. Thus the stackFiles property will be searched and stacks loaded into memory as appropriate.</p><p></p><p>The <b>behavior</b> property does not track changes to the name of the stack and/or substack - if the name of a stack containing behavior objects is changed, then all references to these behaviors will be broken. This apparent strictness is necessary to ensure that behaviors act consistently while LiveCode is running.</p><p></p><p></p><change>As of version 6.1 the behavior property of a control currently being used as a behavior will now be taken into account and result in the child behaviour deferring to the parent behavior in the same way a control defers to its behavior.<p></change><p>For example, let's say you have the following setup:</p><p>field "Action" - behaviour set to button "Derived"</p><p>button "Derived" - behaviour set to button "Root"</p><p>button "Root"</p><p></p><p>Then the message path will be:</p><p>field "Action"</p><p>button "Derived"</p><p>button "Root"</p><p></p><p></p><note> that the synonym <b>parentScript</b> is probably going to be removed before the release of version 3.5, so it should not be used. Please see the Engine Change log in the LiveCode folder for more information. 	</note></comments> </description></doc>