Kanzi  3.9.5
Kanzi Studio API
TriggerConditionItem Interface Reference

Configure trigger conditions. More...

Properties

TriggerConditionOperation ConditionOperation [get, set]
 Gets or sets the comparison operator that you use to compare Value A to Value B: More...
 
object FixedPropertyValue [get, set]
 
bool IsValid [get]
 Gets the validity of the trigger condition. More...
 
Property MessageA [get, set]
 
Property MessageB [get, set]
 
ProjectItem ProjectItemA [get, set]
 
ProjectItem ProjectItemB [get, set]
 
Property PropertyA [get, set]
 
AnimationTargetPropertyAttributeEnum PropertyAttributeA [get, set]
 
AnimationTargetPropertyAttributeEnum PropertyAttributeB [get, set]
 
Property PropertyB [get, set]
 
TriggerConditionTermSourceType TermASource [get, set]
 
TriggerConditionTermSourceType TermBSource [get, set]
 Gets or sets whether the trigger condition compares to a value (Value B) that comes from a property, a message, or a fixed value: More...
 

Detailed Description

Configure trigger conditions.

Trigger conditions enable you to set which conditions must be met for the trigger to set off. For example, you can define conditions to set off a trigger when the user selects a specific item in a list box or presses a specific key on their keyboard, or to enable the user to click a button only when that button is visible, or to allow the user to scroll a Scroll View node only when a specific Page node is active.

To configure a trigger condition, define Type of A and Type of B, and a comparison operation that you use to compare Type of A to Type of B:

See also
TriggerNodeComponent, TriggerActionItem, NodeComponentHost

Examples

To create and configure a trigger condition using a value from a property:

// Create and configure a trigger condition which makes a trigger set off only
// when the Visible property of the Button 2D node is enabled:
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Button 2D node in the RootPage node.
var button =
studio.ActiveProject.CreateProjectItem<Button2D>(rootPage.GenerateUniqueChildName("Button 2D"), rootPage);
// Add the Visible property for the Button 2D node and set it to true.
button.Set(Properties.NodeVisible, true);
// Get the first Button: Click trigger in the Button 2D node.
var clickTrigger =
button.Triggers.First(
trigger => trigger.Get(
Properties.TriggerMessageType) == studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.Button.Click"));
// Create a trigger condition for the first Button: Click trigger in the Button 2D node.
var triggerCondition = clickTrigger.CreateCondition();
// Set the trigger condition to compare a value that comes from a property.
triggerCondition.TermASource = TriggerConditionTermSourceType.FROM_PROPERTY;
// Set the node the property of which you want to compare to Button 2D.
triggerCondition.ProjectItemA = button;
// Set the property which you want to compare to Visible.
triggerCondition.PropertyA = Properties.NodeVisible;
// Set the property attribute which you want to compare.
// Because you want to compare the NodeVisible property and not its attribute, use WHOLE_PROPERTY.
triggerCondition.PropertyAttributeA = AnimationTargetPropertyAttributeEnum.WHOLE_PROPERTY;
// Set the comparison operation to =.
triggerCondition.ConditionOperation = TriggerConditionOperation.EQUALS;
// Set the trigger condition to compare to a fixed value.
triggerCondition.TermBSource = TriggerConditionTermSourceType.FIXED;
// Set the fixed value to true.
triggerCondition.FixedPropertyValue = true;
}

To create and configure a trigger condition using a value from a list box message:

// Create and configure a trigger condition which makes a trigger set off only
// when the user selects any item but the first one in a Grid List Box 2D node:
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Grid List Box 2D node in the RootPage node.
var listBox =
studio.ActiveProject.CreateProjectItem<GridListBox2D>(rootPage.GenerateUniqueChildName("Grid List Box 2D"), rootPage);
// Create a List Box: Item Selected trigger in the Grid List Box 2D node.
var itemSelectedTrigger = listBox.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName("Kanzi.MessageTrigger"));
itemSelectedTrigger.Set(Properties.TriggerMessageType, studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.ListBox.ItemSelected"));
// Create a trigger condition for the List Box: Item Selected trigger in the Grid List Box 2D node.
var triggerCondition = itemSelectedTrigger.CreateCondition();
// Set the trigger condition to compare a value that comes from a message.
triggerCondition.TermASource = TriggerConditionTermSourceType.FROM_MESSAGE;
// Set the message argument which you want to compare to the index of the selected item of the Grid List Box 2D node.
triggerCondition.MessageA = Properties.ListBoxConceptItemSelectedMessageArgumentsSelectedItemIndex;
// Set the comparison operation to !=.
triggerCondition.ConditionOperation = TriggerConditionOperation.DIFFERENT;
// Set the trigger condition to compare to a fixed value.
triggerCondition.TermBSource = TriggerConditionTermSourceType.FIXED;
// Set the fixed value to 0 to make the trigger set off when the user selects any item but the first one in the Grid List Box 2D node.
triggerCondition.FixedPropertyValue = 0;
}

To create and configure a trigger condition using a value from a keyboard message:

// Create and configure a trigger condition that makes a trigger set off when the user presses the Enter key:
public void Execute(PluginCommandParameter parameter)
{
// The keyboard input code for the Enter key is 46.
// In the Kanzi UI documentation see Reference > Keyboard input codes reference.
const int EnterKeyCode = 46;
// Create a Key Pressed trigger in the Screen node.
var keyPressedTrigger = studio.ActiveProject.Screen.CreateTrigger(studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName("Kanzi.MessageTrigger"));
keyPressedTrigger.Set(Properties.TriggerMessageType, studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.KeyPressed"));
// Create a trigger condition for the Key Pressed trigger in the Screen node.
var triggerCondition = keyPressedTrigger.CreateCondition();
// Set the trigger condition to compare a value that comes from a message.
triggerCondition.TermASource = TriggerConditionTermSourceType.FROM_MESSAGE;
// Set the message argument which you want to compare to the target key.
triggerCondition.MessageA = Properties.InputMessageArgumentKey;
// Set the comparison operation to =.
triggerCondition.ConditionOperation = TriggerConditionOperation.EQUALS;
// Set the trigger condition to compare to a fixed value.
triggerCondition.TermBSource = TriggerConditionTermSourceType.FIXED;
// To make the trigger set off when the user presses the Enter key, set the fixed value to the Enter key.
triggerCondition.FixedPropertyValue = EnterKeyCode;
// Create a Write Log action in the Key Pressed trigger.
var writeLogAction = keyPressedTrigger.CreateAction(studio.ActiveProject.TriggerActionTypeLibrary.GetItemByName("Kanzi.WriteLogAction"));
// In the Write Log action set Log Text to "Enter pressed".
writeLogAction.Set(Properties.WriteLogActionLogText, "Enter pressed");
// Get the Key Manipulator node component type.
var keyManipulatorType = studio.ActiveProject.NodeComponentTypeLibrary.GetItemByName(NodeComponentTypeNames.KeyManipulatorComponent);
// Create a Key Manipulator component named Key Manipulator in the Screen node.
var keyManipulator = studio.ActiveProject.Screen.CreateNodeComponent("Key Manipulator", keyManipulatorType);
// Set the Logical Key property to the Enter key.
keyManipulator.Set(Properties.KeyManipulatorComponentLogicalKey, EnterKeyCode);
}

Property Documentation

◆ ConditionOperation

TriggerConditionOperation ConditionOperation
getset

Gets or sets the comparison operator that you use to compare Value A to Value B:

  • NONE for none
  • EQUALS for =
  • DIFFERENT for !=
  • SMALLER for <
  • BIGGER for >
  • SMALLER_OR_EQUALS for <=
  • BIGGER_OR_EQUALS for >=

◆ FixedPropertyValue

object FixedPropertyValue
getset

Gets or sets the fixed value to which you want to compare.

To use this property, set TermBSource to FIXED.

See also
TermBSource

◆ IsValid

bool IsValid
get

Gets the validity of the trigger condition.

Returns
True if the trigger condition is valid, otherwise false.

◆ MessageA

Property MessageA
getset

Gets or sets the message argument which you want to compare.

To use this property, set TermASource to FROM_MESSAGE.

See also
TermASource

◆ MessageB

Property MessageB
getset

Gets or sets the message argument to which you want to compare.

To use this property, set TermBSource to FROM_MESSAGE.

See also
TermBSource

◆ ProjectItemA

ProjectItem ProjectItemA
getset

Gets or sets the project item a property of which you want to compare.

To use this property, set:

  • TermASource to FROM_PROPERTY.
  • PropertyA to the property which you want to compare
  • PropertyAttributeA to the property attribute which you want to compare
See also
TermASource, PropertyA, PropertyAttributeA

◆ ProjectItemB

ProjectItem ProjectItemB
getset

Gets or sets the node to a property of which you want to compare.

To use this property, set:

  • TermBSource to FROM_PROPERTY.
  • PropertyB to the property which you want to compare
  • PropertyAttributeB to the property attribute which you want to compare
See also
TermBSource, PropertyB, PropertyAttributeB

◆ PropertyA

Property PropertyA
getset

Gets or sets the property which you want to compare.

To use this property, set:

  • TermASource to FROM_PROPERTY
  • ProjectItemA to the project item the property of which you want to compare
  • PropertyAttributeA to the property attribute which you want to compare
See also
TermASource, ProjectItemA, PropertyAttributeA

◆ PropertyAttributeA

AnimationTargetPropertyAttributeEnum PropertyAttributeA
getset

Gets or sets the property attribute which you want to compare.

To compare the whole property instead of an attribute, use WHOLE_PROPERTY.

To use this property, set:

  • TermASource to FROM_PROPERTY
  • ProjectItemA to the project item the property of which you want to compare
  • PropertyA to the property which you want to compare
See also
TermASource, ProjectItemA, PropertyA

◆ PropertyAttributeB

AnimationTargetPropertyAttributeEnum PropertyAttributeB
getset

Gets or sets the property attribute to which you want to compare.

To compare to the whole property instead of an attribute, use WHOLE_PROPERTY.

To use this property, set:

  • TermBSource to FROM_PROPERTY
  • ProjectItemB to the project item to the property of which you want to compare
  • PropertyB to the property to which you want to compare
See also
TermBSource, ProjectItemB, PropertyB

◆ PropertyB

Property PropertyB
getset

Gets or sets the property to which you want to compare.

To use this property, set:

  • TermBSource to FROM_PROPERTY
  • ProjectItemB to the project item to the property of which you want to compare
  • PropertyAttributeB to the property attribute to which you want to compare
See also
TermBSource, ProjectItemB, PropertyAttributeB

◆ TermASource

TriggerConditionTermSourceType TermASource
getset

Gets or sets whether the trigger condition compares a value (Value A) that comes from a property or a message:

  • FROM_PROPERTY for property
  • FROM_MESSAGE for message

◆ TermBSource

TriggerConditionTermSourceType TermBSource
getset

Gets or sets whether the trigger condition compares to a value (Value B) that comes from a property, a message, or a fixed value:

  • FIXED for fixed value
  • FROM_PROPERTY for property
  • FROM_MESSAGE for message