Exercise - Module interaction
We will see how we can make modules interact between each other.
We will create a very simple view with modules that interact with each other. The goal is to have a code editor in which you can write some text. The text will be passed to a module that is capable of displaying it. We will then create a second editor in which you can type a color to dynamically change the background color of a module.
A.
- Go to the preferences of the code editor (via contextual menu or by clicking the wrench in the right upper corner). Go to the "Variables out" tab. The event column specifies the type of event on which a variable out should be generated. Select "The value in the editor has changed". The selection column specifies what variable should be emitted. In this case select "String containing the code". Leave the jpath and filter columns empty. In the "To variable" column, select a variable name of your choice.
- Open the preferences of the Display value module and go to the "Variables in" tab. The reference column describes the type of data you are sending the module (here there is just one choice, but some modules accept different types of data). Select "Any displayable object". In "from Variable" type in the same name you chose for the "Variable out" in the code editor.
You should now see that the text in the bottom is updated whenever you type text in the code editor! You can see the connection between the modules graphically by clicking "View diagram "in the contextual menu.
B.
- Create a second code_editor module. Configure the variables in and out so that you can dynamically change the background color of the display value module. Tip: the color should be a valid css color, for example "#FF0000" or "red".