Example Code

Moving Controls on a Front Panel Using Keyboard Inputs in an Event Structure in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example illustrates how to use a keyboard input to trigger an event in an Event Structure to move a control on the front panel of the VI while the VI is running.

  

Description

This example utilizes event structures to catch keyboard events. When a particular keyboard event occurs, we read from the Position property node of a front panel control, and based on the key that was pressed, edit Position and write out the new position to the property node. Notice in the VI snippet below, if the "Down" key is pressed, we add 1 to the "Top" value in the control's Position property. This moves the control down by one pixel. This example uses the Up, Down, Left, and Right arrow keys to move the control, but this can be modified to use whatever keys you desire. Also, you can modify this example to move in larger jumps if that is desired.

  

Steps to Implement or Execute Code

  1. Download and open the VI.
  2. Run the VI.
  3. Press one of your four arrow keys (down, left, right, up). Notice that the control moves.
  4. To stop the VI, press the stop button.

 Requirements

Software

LabVIEW 2012 or later

 

 Additional Information or References

VI Block Diagram

 4903.PNG

 

 **This document has been updated to meet the current required format for the NI Code Exchange. *

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.