In LabVIEW, Boolean controls have a configurable mechanical action that lets them resemble the behavior of buttons on physical instruments, such as oscilloscopes or multimeters.

There are two general categories of mechanical action: switch and latch. Switch and latch actions are similar in that they both change the value of the Boolean control. The actions differ in how the value of the control reverts to the previous value.

  • Switch action—Allows only the user to revert the value of the control back to the previous value.
  • Latch action—Allows the VI that reads the control to revert the value of the control back to the previous value. Also allows the user to return the value of the control to the previous value, but only if the user does so before the VI reads the control.
    Note Latch actions cannot be used with local variables. Latch actions used with event structures typically have their terminals placed inside the Value Change event frame.
  • To define the mechanical action for a Boolean control, right-click the control and select the behavior from the Mechanical Action menu. Table 8. Boolean Control Mechanical Actions provides more information about the three types of switch behaviors and latch behaviors.

    The glyphs within the icon in the table for each mechanical action have the following meanings:

  • m—The motion of the mouse button when you operate the control.
  • v—The output value of the control.
  • RD—The point in time the VI reads the control.
  • Table 8. Boolean Control Mechanical Actions
    Mechanical Action Behavior Illustration Behavior Example
    Switch When Pressed Illustration of behavior of the Switch When Pressed mechanical action for Boolean controls.
    • Changes the current value as soon as you click the control.
    • Retains the new value until you click the control again.
    Light switch: The light turns on as soon as you switch the control. The light stays in that state until you switch the control again.
    Switch When Released Illustration of behavior of the Switch When Released mechanical action for Boolean controls.
    • Changes the current value when you release the mouse button.
    • Retains the new value until you click the control again.
    Checkbox: The checkbox changes its value only after you release the mouse button. This gives you the ability to reconsider your choice after clicking by moving the cursor away from the checkbox before releasing the mouse button.
    Switch Until Released Illustration of behavior of the Switch Until Released mechanical action for Boolean controls.
    • Changes the current value only when you click and hold the mouse button down.
    • Reverts to the previous value when you release the mouse button.
    Doorbell: The bell rings as soon as you press the button. The bell continues to ring until you release the button.
    Latch When Pressed Illustration of behavior of the Latch When Pressed mechanical action for Boolean controls.
    • Changes the current value as soon as you click the control.
    • Reverts to the previous value after the VI reads the control.
    Emergency stop button: The button stops the system as soon as you press the button. The button resets as soon as the system reads the change in value, allowing for the button to be pressed again.
    Latch When Released Illustration of behavior of the Latch When Released mechanical action for Boolean controls.
    • Changes the current value when you release the mouse button.
    • Reverts to the previous value after the VI reads the control.
    Close button: The button closes the program only after you release the mouse button and the application reads the change in value. This gives you the ability to reconsider your choice after clicking by moving the cursor away from the button before releasing the mouse button.
    Latch Until Released Illustration of behavior of the Latch Until Released mechanical action for Boolean controls.
    • Changes the current value only when you click and hold the mouse button down.
    • Once you release the mouse button, the value will revert to the previous value after the VI reads the control.
    Robot movement control: The movement control informs the system of the robot to move the robot while the control is pressed down. Once the control is released, and the system of the robot has read the control, the robot goes back to its previous state of non-movement.
    Note When you assign a keyboard shortcut to the mechanical action of a Boolean control, the keyboard toggles the value. For example, when you assign a keyboard shortcut to a Boolean control and set the keyboard shortcut to one of the latching mechanical actions, the button unlatches when read.
    Note You cannot use any latch action for objects with a local variable. If you configure your Boolean value with a latching mechanical action, the Value property and the Value (Signaling) property return an error when the VI is in a non-idle state, such as when the VI is running or reserved to run. Due to race conditions that can occur when you have a Boolean value with latching mechanical action, you cannot programmatically read Boolean values that are set with a latching mechanical action.
    Note (FPGA Module) On FPGA targets, use Switch When Pressed, Switch When Released, or Switch Until Released as a control that changes the current value once a new value is written from the host VI to the FPGA target, and retains the new value until another value is written from the host VI again. Use Latch When Pressed, Latch When Released, or Latch Until Released as a control that only changes the current value when a new value is written from the host VI to the FPGA target, and reverts to the previous value once the new value has been read by the FPGA target.