You are here: Designing an Application > Add Actions > Functions

Functions Actions

From the Functions section of the list of actions available along the left column of the Action Editor, you can add any of the following four actions. Click an action for instructions on how to add it to an action sequence.

Action Description
Add Local Variable Adds a variable that is available within a function. Local variable can be of type Constant or Expression and take the following data type: String, Number, Boolean and or Collection.
Add Snippet

Opens the code editor where you can write or paste a code snippet for use within a function.

Add Swift Snippet Available only for the Watch channel. Opens the code editor where you can write or paste a Swift code snippet for use within a function. To create action sequences for watchOS, you must use Swift; watchOS does not support JavaScript.
Call Actions

Calls the action of your choosing from a list of available actions. To use this feature, you have to have already set up at least one action in the Project Explorer, on the Project tab, under the Actions section.

Invoke Function

Invokes the function of your choosing from a list of available functions.

Add Local Variable

To add a local variable, do the following:

  1. From the Project tab of the Project Explorer, select the widget you want to apply the action to. Once it’s highlighted on the Visualizer Canvas, right-click it, and then select one of the action sequences, such as onTouchStart. Doing so opens the Action Editor and creates an action sequence for you to configure.
  2. From the list of actions available along the left column of the Action Editor, click Add Local Variable from the Functions section. The action is added to the action sequence and is the current action of focus.
  3. In the bottom pane of the Action Editor, in the Name text box, enter a name for the variable.
  4. From the Value Type drop-down list, select a value type, either Constant or Expression.
  5. In the Value field, enter the value of the local variable.
  6. Save the action by pressing Ctrl+S.

Add Snippet

To add a code snippet, do the following:

  1. From the Project tab of the Project Explorer, select the widget you want to apply the action to. Once it’s highlighted on the Visualizer Canvas, right-click it, and then select one of the action sequences, such as onTouchStart. Doing so opens the Action Editor and creates an action sequence for you to configure.
  2. From the list of actions available along the left column of the Action Editor, click Add Snippet from the Functions section. The action is added to the action sequence and is the current action of focus.
  3. In the bottom pane of the Action Editor, in the code editor, enter the code that you want to add, or paste it in from another source by pressing Ctrl+V.
  4. Save the action by pressing Ctrl+S.

Add Swift Snippet

In Kony Visualizer, action sequences for watchOS are written using the Swift programming language; watchOS does not support JavaScript. For more information, see Swift on the Apple Developer site.

You can access all the Swift code snippets in your project from the Watch folder, located under Modules on the Project pane of the Project Explorer.

Important: For projects with Watch action sequences written in JavaScript, created in Kony Visualizer 7.0, to continue working on such a project in Kony Visualizer 7.0.3 or later, those Watch action sequences will have to be rewritten in Swift. When you attempt to open such a project in Kony Visualizer 7.0.3, a dialog box appears stating that continuing will cause all Watch action sequences with JavaScript to be dropped, and they will need to be rewritten. You can choose to continue, which opens the project and drops those Watch action sequences with JavaScript, or cancel, which doesn't open the project and leaves it unchanged.

To add a Swift code snippet, do the following:

  1. From the Project tab of the Project Explorer, navigate to the Watch channel, locate the form or widget you want to apply the action to, click its context menu arrow, and then select one of the action sequences, such as onTouchStart. Doing so opens the Action Editor and creates an action sequence for you to configure.
  2. Click Add Swift Snippet from the Functions section. The action is added to the action sequence and is the current action of focus.
  3. In the bottom pane of the Action Editor, in the code editor, enter the Swift code that you want to add, or paste it in from another source by pressing Ctrl+V.
  4. Save the action by pressing Ctrl+S.

Call Action

To use this feature, you have to have already set up at least one action in the Project Explorer, on the Project tab, under the Actions section.

Once you have configured the Call Action function, you can navigate to and edit the source action that the function is calling.

To call an action, do the following:

  1. From the Project tab of the Project Explorer, select the widget you want to apply the action to. Once it’s highlighted on the Visualizer Canvas, right-click it, and then select one of the action sequences, such as onTouchStart. Doing so opens the Action Editor and creates an action sequence for you to configure.
  2. From the list of actions available along the left column of the Action Editor, click Call Action from the Functions section. The action is added to the action sequence and is the current action of focus.
  3. In the bottom pane of the Action Editor, from the Action Type drop-down list box, select the action you want to call.
  4. Save the action by pressing Ctrl+S.

To edit the source action that the function is calling, do the following:

  1. Open the action sequence that has the Call Action function.
  2. Right-click the Call Action function, and then click Edit Source Action. The action opens in the Action Editor.

Invoke Function

With the Invoke Function action, you choose the function you want to invoke from the Function Name list. To locate in the code the function you're invoking, you use the Navigate to Definition feature.

To invoke a function, do the following:

  1. From the Project tab of the Project Explorer, select the widget you want to apply the action to. Once it’s highlighted on the Visualizer Canvas, right-click it, and then select one of the action sequences, such as onTouchStart. Doing so opens the Action Editor and creates an action sequence for you to configure.
  2. From the list of actions available along the left column of the Action Editor, click Invoke Function from the Functions section. The action is added to the action sequence and is the current action of focus.
  3. In the bottom pane of the Action Editor, from the Function Name drop-down list box, select the function you want to invoke.
  4. To locate the function you've chosen in the code, click Navigate to Definition. Kony Visualizer opens the asset that contains the function to the line number where the function begins.
  5. Save the action by pressing Ctrl+S.

 

 

 

 

Rev Author Edits
7.0 NMK NMK
7.1 NMK NMK
Copyright © 2013 Kony, Inc. All rights reserved.