Built-in macros: $composer

The $composer macro is replaced by a boolean literal true or false, depending on whether the current code is compiled in context of the Composer window or not.

Content

true

false

Discussion

If the macro results in the value true, the code is compiled for the execution within the Canvas area of the Composer. If the macro results in the value false, the code is compiled for the execution within the Prototyper window or the code is compiled for the target system.

This macro can be evaluated within Chora expressions or you can use it to conditionally compile the application. For example, if you want a view to appear with a different color when arranging the view within the Composer window, you can implement following code in the Init() method of your component:

$if $composer SomeView.Color = #FF0000FF; $endif

This color alternation will affect the appearance of the view in the Composer window only. When generating code for the target system or when executing the application in the Prototyper window it has no effect. Similarly the macro $composer can be used inside a regular Chora expression wherever a boolean operand is allowed. For example, you can set a property of an object to the value true or false depending on whether the code is executed in Composer or not:

SomeObject.SomeProperty = $composer;