Using custom states

Getting advanced with Touch Portal

This overview will show you how to create a toggle button that toggles between three states using Values.

Step 01: What is a Value?

In Touch Portal a Value is just that. It is an object that holds a value. It is just that simple. You can of course manipulate this value using all sorts of actions but in the end, a Value is just a value.

If you choose "Values" in the main menu you will open the Values screen. This section shows your list of Values. You can view this as a grid or as a list (2). Each Value is represented by one entry in the list (3). You can give your Value a color so you will be able to group the Values that belong with each other. The entry will show you the current value the Value has, which can be handy when you are testing your logic.

Step 02: Creating a new Value

We want our Value to hold 3 values to be able to simulate a button with 3 states. Let's make our Value for our 3-state-toggle, press the "Add Value..." button on the Values section (1) to create a new custom state.

Now fill in the custom state fields like below. This will create a Value with a the name "Advanced Toggle State". We will use this later on in our flows.

Click on "Save" to save the Value.



Step 02: Create the toggle code

To toggle between 3 states it gets a bit complex but we need to check the state and then change the state to another one in a logical order. In the image below we change the state from GREEN to BLUE, from BLUE to RED and from RED to GREEN. We use nested IF statements so that we ensure the state is only changed one time when you press the button.



Step 03: Create the events

The events tab is a bit more familiar. We just add an event that listens to a Value change. In our case we just listen for the created Value and act according the value of that event. So in our case it will change the button to red when the state value is "red". The same goes for blue and green.



End Result

If you press the newly created button a few times you should be toggling between the states "red", "green" and "blue". The background should change to the color of the state.





Pro Upgrade - required If you are using the base free version of Touch Portal without the Pro upgrade, you cannot use the custom states.



Back to Guide Overview