Step 4 - Create interactions¶
In this step, you learn how to create interactions in your application with triggers and actions.
Create interactions¶
Use triggers and actions to create interactions. Use triggers to set off actions, such as setting a property to a certain value or setting the state of an application.
In Kanzi Studio, you add and set triggers and actions in the Node Components window.
You can find the Node Components window in the same group as the Properties window.
In this section, you create a button and use triggers and actions to write a message to the Log window.
To create interactions:
In the Activity Browser window, below the Root Parallel Activity Host, click
, select Create Activity, and name the Activity and its prefab Navigation. In the side panel, set the InitiallyActive property to enabled.In this Activity, you create application navigation that you want to be visible on all application screens.
In the Prefabs window, press Alt and right-click the Navigation prefab, select Button 2D, and name it Next.
Most of the Kanzi nodes set only the node layout and functionality. This gives you the flexibility to make nodes look the way you want them to look.
The content that you place in the prefab of the Navigation Activity is visible in the whole application, because it is parallel to the Exclusive Activity Host that shows the application screens and because you set it to be active already at startup.
In the Preview, click
to enter the Analyze mode, right-click
, and select Borders of 2D nodes.Use the Analyze mode in the Preview window to inspect the structure and performance of your application.
Borders of 2D nodes outlines the borders of 2D nodes with striped lines.
For example, this allows you to see 2D nodes that do not have a visual representation. The Button 2D node you created in the previous step is in the top-left corner of the Preview window.
In the Node Tree window, select the Next node. In the Node Components window, in the Button: Click message trigger, press Alt and right-click Actions, and select Write Log.
Use the Write Log action to print a message to the Log window.
In the Write Log action next to the Log Text property, click Enter Operation and select <Name>.
Use the <Name> macro to print to the Log window the type of the node that contains this action.
In the main menu select Window > Log to open the Log window.
Kanzi prints to the Log window messages, warnings, and errors.
In the Preview window, when you click the area of the Next Button 2D node, you set off the Button: Click trigger that executes the Write Log action that writes the name of the node to the Log window.
See also¶
To learn more about creating buttons, complete Tutorial: Creating a button.
To learn more about the Write Log action, see Using Write Log action.
To learn more about triggers and actions, see Triggers.
To learn more about the Preview window tools, see Editing your application in the Preview.