Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Action

Index

Constructors

  • new Action(name: string, callback: Function): Action
  • Create an Action that can show up inside Umajin App Creator.

    var uActions = require('u-actions');
    new uActions.Action('Say hello', sayHello).register();
    function sayHello() {
    uActions.showPopup('Hello!');
    }

    Parameters

    • name: string

      Display name of the Action that will appear in Umajin App Creator.

    • callback: Function

      Reference to the function that will be called when the Action is fired.

    Returns Action

Methods

  • addBooleanParameter(name: string, defaultValue?: boolean): Action
  • Add a Boolean parameter to the action. The value is sent to the callback.

    var uActions = require('u-actions');
    new uActions.Action('Say hello', sayHello)
    .addBooleanParameter('Show in popup?', true)
    .register();
    function sayHello(showInPopup) {
    var greeting = 'Hello world';
    if (showInPopup) {
    uActions.showPopup(greeting);
    }
    }

    Parameters

    • name: string

      Name of the parameter that will show in Umajin App Creator.

    • Optional defaultValue: boolean

      The initial value the parameter is set to.

    Returns Action

  • addDescription(description: string): any
  • Add a custom description to the action.

    var uActions = require('u-actions');
    var Action = uActions.Action;
    new Action('Welcome new user', welcomeNewUser)
    .addDescription('This is the demo function.')
    .addIcon('images/presets/icon_loyalty_on.png')
    .register();
    function welcomeNewUser() {
    uActions.showPopup('Welcome to Umajin!');
    }

    Parameters

    • description: string

    Returns any

  • addHardCodedParameter(name: string, value?: string): Action
  • Add a Hard Coded parameter to the action. The value is sent to the callback. The user can not change this value.

    Parameters

    • name: string

      Name of the parameter.

    • Optional value: string

    Returns Action

  • addIcon(filename: string): Action
  • Add a custom icon to the action. The image could be seen above the action's name in the action selector.

    new uActions.Action('Say hello', sayHello)
    .addIcon('images/presets/icon_loyalty_on.png')
    .register();
    function sayHello(showInPopup) {
    uActions.showPopup('Hello');
    }

    Parameters

    • filename: string

      Can be the name of the icon file (with or without extension) inside the scripts folder, or a path to an image inside your project folder.

    Returns Action

  • addIntParameter(name: string, defaultValue: number, min: number, max: number): Action
  • Add a Int parameter to the action, that shows a slider. The value is sent to the callback.

    var uActions = require('u-actions');
    new uActions.Action('show degree', showDegree)
    .addIntParameter('degree',5,0,10)
    .register();
    function showDegree(degree) {
    uActions.showPopup('The degree is: '+ degree+ ' Celsius.');
    }

    Parameters

    • name: string

      Name of the parameter that will show in Umajin App Creator.

    • defaultValue: number

      The initial value the parameter is set to.

    • min: number

      The minimum value that the user can set.

    • max: number

      The maximum value that the user can set.

    Returns Action

  • Add a typed parameter to the action. The value is sent to the callback.

    var uActions = require('u-actions');
    new uActions.Action('Say hello', sayHello)
    .addStringParameter('Your Name', 'World')
    .addParameter('Text Output', uActions.ParamType.TEXT)
    .register();
    function sayHello(yourName, textOutput) {
    var greeting = 'Hello ' + yourName + '!';
    textOutput.text = greeting;
    }

    Parameters

    • name: string

      Name of the parameter that will show in Umajin App Creator.

    • Optional type: ParamType

      Parameter type can be any of the parameter types from "actions.ParamType". If none is specified, then no filter is applied.

    Returns Action

  • addRealParameter(name: string, defaultValue: number, min: number, max: number): Action
  • Add a Real parameter to the action, that shows a slider. The value is sent to the callback.

    var uActions = require('u-actions');
    new uActions.Action('measure the distance', measurement)
    .addRealParameter('distance',5.5,0.0,10.5)
    .addParameter('result',uActions.ParamType.TEXT)
    .register();
    function measurement(distance,reuslt) {
    reuslt.text='The distance is: '+distance+ ' cm.';
    }

    Parameters

    • name: string

      Name of the parameter that will show in Umajin App Creator.

    • defaultValue: number

      The initial value the parameter is set to.

    • min: number

      The minimum value that the user can set.

    • max: number

      The maximum value that the user can set.

    Returns Action

  • addSliderParameter(name: string, defaultValue: number, min: number, max: number, step: number): Action
  • Add a Slider parameter to the action, that shows a slider. The value is sent to the callback.

    var uActions = require('u-actions');
    new uActions.Action('measure the distance', measurement)
    .addSliderParameter('distance',6,0,10,2)
    .addParameter('result',uActions.ParamType.TEXT)
    .register();
    function measurement(distance,reuslt) {
    reuslt.text='The distance is: '+distance+ ' cm.';
    }

    Parameters

    • name: string

      Name of the parameter that will show in Umajin App Creator.

    • defaultValue: number

      The initial value the parameter is set to.

    • min: number

      The minimum value that the user can set.

    • max: number

      The maximum value that the user can set.

    • step: number

      The size that slider increments by.

    Returns Action

  • addStepperParameter(name: string, defaultValue: number, min: number, max: number, step: number): Action
  • Add a Stepper parameter to the action, that shows a stepper. The value is sent to the callback.

    var uActions = require('u-actions');
    new uActions.Action('measure the distance', measurement)
    .addStepperParameter('distance',6,0,15,1.5)
    .addParameter('result',uActions.ParamType.TEXT)
    .register();
    function measurement(distance,reuslt) {
    reuslt.text='The distance is: '+distance+ ' cm.';
    }

    Parameters

    • name: string

      Name of the parameter that will show in Umajin App Creator.

    • defaultValue: number

      The initial value the parameter is set to.

    • min: number

      The minimum value that the user can set.

    • max: number

      The maximum value that the user can set.

    • step: number

      The size that stepper increments by.

    Returns Action

  • addStringParameter(name: string, defaultValue?: string): Action
  • Add a String parameter to the action. The value is sent to the callback.

    var uActions = require('u-actions');
    var Action = uActions.Action;
    new Action('Welcome new user', welcomeNewUser)
    .addStringParameter('Your name','Tom')
    .register();
    function welcomeNewUser(name) {
    uActions.showPopup('Welcome '+name+ ' !');
    }

    Parameters

    • name: string

      Name of the parameter that will show in Umajin App Creator.

    • Optional defaultValue: string

      The initial value the parameter is set to.

    Returns Action

  • Call register once the Action is ready, to add it into Umajin App Creator.

    var uActions = require('u-actions');
    var Action = uActions.Action;
    new Action('Demo action', demoAction)
    .register();
    function demoAction() {
    uActions.showPopup('Welcome to Umajin!');
    }

    Returns Action