Tips and Tricks

Visibility and Transform

Visibility and Transform are two universal behaviors in Pencil that can be applied to any type of object:


Forced dependencies

Upon changes being made to a specific property, all elements that have at least one behavior referring to that property will be invalidated and the behavior code will be executed. In some special cases, you may want a specific behavior to be executed when a specific property changes even when that property is not explicitly referenced. In this case, add a comment with the format //depends $propertyName to the behavior concerned.

<For ref="text">
    <TextContent>new PlainText("Hello World")</TextContent>
    <Font>new Font()</Font>
        <Arg>new Bound(0, 0, 100, 12) //depends $textColor</Arg>
        <Arg>new Alignment(0, 1)</Arg>