Example Code

Determine if Mouse is within Generic Object Bounds 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

Event structures are very useful in handling mouse interaction with controls on a VI front panel. This functionality, however, is not extended to generic objects, such as decorations. This VI compares the coordinates from a mouse click or movement and determines if the cursor is within the bounds of a specified object.

 

Description

In the main VI TestBounds.vi a generic object reference is passed into an event structure. When a mouse is pressed down within the VI pane, the sub VI Within Object Bounds.vi compares the coordinates of the cursor with the generic object bounds. If the mouse is, in fact, within the bounds, the LED on the main VI lights up.

 

Requirements

  • LabVIEW 2012 (or compatible).

 

Steps to Implement or Execute Code

  1. Run the VI
  2. Click both within and outside of the bounding box. Notice the LED behavior with each click.

 

Additional Information or References

 

testbounds2.pngtestbounds.png

 

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

 

Rick C.

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