In this article, you will learn:
- How to use "Color" variables"
- How to add a specific color to a field in a table
Tulip allows you to dynamically change colors of buttons, gauges and many other widgets.
To accomplish this, you first need to store a color in a variable or field in a table.
Here's how to create a new Color variable via the Variables dialog in the Context Pane:
Here's an example of how to set up a "Color" field in a table:
Then, after creating a color variable, you can manually select it in almost every colorpicker by clicking the "Variables" tab in the colorpicker:
That will apply the color stored in the variable to the widget.
This guide will show you a couple common examples of how to use color variables and color fields in apps.
Changing the Color of A Button
Let's say that you have a "Next" button in your app, and you want to change the color based on whether a quality check has been passed.
To start, you should create a variable called "check_status_color" and set the default value to "red" via the Variables dialog in the Context Pane.
Here's where to add a new variable in the Context Pane:
And here is how to create the variable and set it to red:
You want red to be default because a person cannot progress until the quality check has been passed.
Then, set the button color to the correct variable in the Widget pane by clicking "Button Color" and then choosing variables:
Finally, when the quality check is passed, you need to update the color of the variable via the "Data Manipulation" trigger action. Like this:
- "Data Manipulation" "Store" data: "Static Value" "color" (blue) location: "variable" "check_status_color"
One more thing: you might want to add an "if" statement to the "Next" button to prevent the operator from progressing until the quality check is passed.
Here's how to do that using an "if" statement:
- "Variable" "test1" "Is True"
- "Go To Step" "Next"
Toggling a Button's Visibility
In addition to changing color, you can also make a button invisible by changing its transparency dynamically.
To do this, connect a button's color to a color variable as shown above.
To change the transparency of a button, set up a similar "Then" statement to the one above. Then, drag the "transparency" slider all the way to the left.
Here's what the transparency slider on the colorpicker looks like:
Indicating a Status In a Table
Let's say that you want to create a Kamishibai dashboard or track the status of multiple production lines in one place.
You can accomplish this by storing a color value in a table as shown above, then loading it into an app.
First, store a color in a color field in a table. Here's an example of what it will look like:
Then, load the table record into your app.
Finally, add a "Table Record" under the "Text" widget:
Then, choose the Color field from the dropdown in the Context Pane within the record placeholder that you created earlier:
The color field will be automatically added to the open step in a bounding box:
When you open the app in the Tulip Player, you will see the color appear within that bounding box: