Which ones?Īs an example of manipulating Label properties, open the LabelSize program, which has 4 event handlers.
Some Label properties cannot be manipulated by blocks. Setter blocks are commands that change the value associated with the property. Getter blocks are expressions that 'get' or contain the current value of the property. E.g., here are blocks for manipulating the state of Label1. You can specify the initial state of a component in the Properties pane of the Designer window.Īpp Inventor programs can get and set most component properties via blocks. The current values of these properties describe the state of the component. What are some properties of a Label component? Manipulating Component StateĮvery component is characterized by various properties. Also, keep in mind that the way the components appear in the Viewer is only an approximation of how the components will look on the phone. VerticalArrangement and TableArrangement components can also be used to control positioning. Now drag the three buttons into the HorizontalArrangement in the desired order. To organize ButtonWipe, ButtonSmall, and ButtonBig nicely, drag a HorizontalArrangement Component from the Screen Arrangement section of the palette. For example, in the extended version of the PaintPot tutorial, the user creates buttons which change the line size or wipe the screen. Arranging Components on the ScreenĪpp components are organized vertically by default. You need to make sure which action should come first. The order of the commands, or the control flow is important when you make an app. Thinking about control "flowing" through a program will help us understand its behavior. The control dot moves from the top of the stack to the bottom, and when it reaches a command, that command is executed - i.e, the action of that command is performed. When an event handler fires, you can imagine that it creates a karaoke-like control dot that flows through the command stack in its body. However, the execution happens very quickly you will see all the actions happen essentially at the same time. If the stack of commands above is executed, then the phone will first play the sound, then vibrate, then change the label's color to be green, and then label will show the text "CS117 rocks!" When this stack of commands is placed in the body of an event handler (e.g., the event handler), the command will be executed from the top to the bottom.
E.g., all of the following expressions denote the number 500:Ĭommands are shaped so that they naturally compose vertically into a command stack, which is just one big command built out of smaller ones. Larger expressions can be built out of simpler ones by horizontal composition. Expression blocks have leftward-pointing plugs that transmit the value to the socket. These sockets can be filled with expressions which are blocks that denote a value. The need for input values is shown by sockets on the right edge of the command. For example, call Sound1.Vibrate needs to know the number of milliseconds to vibrate, set Label1.BackgroundColor needs to know the new background color of the label, and set Label1.text needs to know the new text string for the label. Some commands require one or more input values (also known as parameters or arguments) to completely specify their action. Here are some sample commands, some of which you may recognize from building HelloPurr: Most command blocks are purple or blue in color.
A command is a block that specifies an action to be performed on the phone (e.g., playing sounds). When an event handler fires, it executes a sequence of commands in its body. When an event occurs on a phone, the corresponding event handler is said to fire, which means it is executed. Here are some examples of event handlers. Most event handlers are green in color and are stored at the top part of each drawer. E.g., when Button1.Click and when AccelerometerSensor1.Shaking in HelloPurr. This is specified by event handler blocks, which used the word when. Event HandlersĪpp Inventor programs describe how the phone should respond to certain events: a button has been pressed, the phone is being shaked, the user is dragging her finger over a canvas, etc. This page explains how basic blocks work.