Example Code

Touch Screen Keyboard and Keypad

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

Download All

Description

Overview:

This example provides tools to implement a pop-up alpha-numeric keyboard or numeric keyboard in a LabVIEW VI or application.  This is extremely useful in touch screen applications.

 

 

Description:

The main elements of this library are the pop-up alpha-numeric keyboard VI (HMI Pop Up Alpha KB.vi), the pop-up numeric keyboard VI (HMI Pop Up Num KP.vi), and an example VI (Sample Usage.vi).  The library also includes custom controls and a keyboard driver.

The keyboard VIs can be used as subVIs, as shown in the example, named Sample Usage.vi.  In this example, when a user clicks on a control on the front panel, either the alpha numeric or numeric keyboard pops up.  This is done using an event structure as shown in the code below.

After the keyboard pops up, the user can type, and then press accept.  This will close the pop-up and the words that were typed will be entered in the control. The keyboard VIs include a setup, an event structure, and a finish.  The event structure executes each time a button is pressed.  

In the event structure, information is passed to the keyboard driver each time there is an event.  The keyboard driver performs an operation and then returns the string and the edit position.  The keyboard driver is works as a functional global variable.  Depending on the command, it will initialize, add a character, replace a character, delete a character, move the cursor to the left or the right, update the edit position, or nothing.  The edit position, string, and maximum character length from the previous iteration of the driver are stored in shift registers.  

 

 

Requirements:

LabVIEW 2012 (or compatible)

 

No hardware is required, but this would be most useful on a touch panel device. 

Information about National Instruments Touch Panel Computers can be found here:https://www.ni.com/en-us/shop/category/hmis-and-displays.html.

 

Steps to Implement or Execute Code:

  1. Unzip the attached folder to your computer
  2. Open the HMI Keyboard Project
  3. Open and run the Sample usage VI
  4. Click on the controls "High Limit" or "Low Limit" to use the numeric keyboard
  5. Click the "Enter Comments" control to use the alpha-numeric keyboard
  6. Switch to "Admin" in the USER dropdown
  7. Type the password, "password" and click "Accept" using the alpha-numeric keyboard
  8. Press "Stop Execution" to stop the VI.

 

Additional Information or References:

To simply run the keyboard VIs ("HMI Pop Up Alpha KB.vi" or "HMI Pop Up Num KP.vi"):

  1. Open and run the VI in LabVIEW 2012 or later
  2. Click (or touch if you're using a touch panel) each letter, number, or symbol to be typed just like on a physical keyboard.
  3. When finished, click/touch accept to submit the entry.  If you do not want to submit, then press cancel.

To implement a keyboard in a VI:

  1. Use the keyboard VI as a subVI using either of these methods:
    1. Drag the VI icon from the Keyboard VI front panel to the block diagram of your VI
    2. In your functions pallette, select "Select a VI..." and then browse to the VI
  2. If you would like the keyboard to pop up in response to an event such as clicking a text control, place the subVI in an event structure and program it for the appropriate event.  This can be seen in the example VI provided (Sample Usage.vi).

 

 

 Sample Usage Example VI Block Diagram

BD of Sample Usage.PNG

 

Alpha-Numeric Keyboard Front Panel

keyboard.PNG

 

 

Alpha-Numeric Keyboard Block Diagram

BD of Alpha KB.PNG

 

Numeric Keyboard Front Panel

FP of Num KB.PNG

 

 

 Numeric Keyboard Block diagram

 BD of Num KB.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.