Calculator Custom Widget Unit Test
  • 21 Feb 2024
  • 1 Minute to read
  • Contributors

Calculator Custom Widget Unit Test


Article Summary

To download the app, visit: Library

Calculator Custom Widget Unit Test

This application describes how to setup and use the Calculator custom widget

Purpose

The purpose of the Calculator Unit Test is to allow users to learn and understand how to setup and use the Calculator custom widget in their Tulip applications. Custom widgets are coded widgets that sit on top of the Tulip platform to give additional functionality that is not currently part of the main platform. The Calculator Custom Widget is an example to demonstrate how to write a single trigger applied across multiple buttons. The primary benefit of this custom widget is that it works as a standard calculator. It demonstrates how a grid (5 rows and 4 columns) of buttons can be formed in a widget.

Setup

Custom Widget Plugins interact with your application through the use of properties and events. Properties are the shared data that exists between your application and widget, while events are signals that your widget can send to your application. In your app editor you can build triggers based off these events. Events can be made to send data to your application as well.

The Calculator Custom Widget makes use of zero properties and two events.The first event being used in this custom widget is called 'Clicked' and this event fires when the user presses any button and it returns the value of the button. The second event being used in this custom widget is called 'Result' and this event fires when the '=' button is pressed and it returns the result of the math expression.

How it Works

The Calculator Custom Widget allows you to perform mathematical calculations and display the results of these calculations. The main purpose of this unit test is to demonstrate how to write a single trigger applied across multiple Buttons. An example of how the calculator custom widget works can be seen in the GIF below.


Was this article helpful?