LabWindows/CVI User Group Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows/CVI Tip: Understanding UI Events and Event Data

LabWindows/CVI User Interface Events Overview

As you may already know, every time your end user performs an action within the GUI, such as selecting a menu item or typing a value into a control, LabWindows/CVI generates one or more “events”. By implementing event callback functions, your program can recognize events and execute code in response to them. The Events Overview help topic contains a complete list of LabWindows/CVI events.

 

What Events get Generated for a Particular Action?

2012-11-28_2311.pngOne way to get a sense of what events get generated for a particular user action is to use the Operate Tool in the user interface editor. When you are in the operate mode, events display in the status bar at the bottom of the workspace window. These event displays have a built-in delay to give you time to see each event. Panel grid lines do not appear in operate mode. However, even with a delay, it can be difficult to remember which exact events were generated.

 

A second, better method is to use the example program described below.

 

Use the Events.cws Example to See All Generated Events and Event Information

    1. Launch the Example Finder from the LabWindows/CVI welcome screen or from Help > Find Examples in the LabWindows/CVI toolbar.

 

    2. Navigate to Building User Interfaces > Acquiring User Input > General > events.cws as shown below

 

         2012-11-28_2225.png

This example illustrates how to recognize many of the low-level events and event-related information that LabWindows/CVI passes from the user interface to your program.  Each UI callback function will receive the events generated during runtime, and display the event information graphically.  Notice that for all mouse click events, the X and Y coordinates of the mouse are also updated.  For KEYPRESS events, the ASCII key code of the key typed is received, instead of the mouse X and Y coordinates.

 

     3. Select which events you want to capture and click through the tabs. You will see generated events appear in real time along with event information.

 

Events_UI.png

 

Additional Resources in LabWindows/CVI Help

  1. Processing Events
  2. Responding to Events in a Graphical User Interface
  3. Using Callback functions to respond to User Interface Events
  4. Callback Schemes
  5. Callback Precedence
  6. Receiving Events
  7. Swallowing Events
  8. Posting Events
  9. Queuing Events
  10. Simulating Events

 

Did you find this tip useful? Rate this document or add a comment below.

Receive Tips and Tricks in the LabWindows/CVI Quarterly Newsletter - sign up at ni.com/cvinews

National Instruments
Comments
ASIC_LabRat
Member
Member
on

How do you make the "swallow event" work? Change the Control Mode to "Normal"

ebalci
Active Participant
Active Participant
on

The event is swallowed if your callback returns a non-zero value.

By default, CVI's callback function generator places "return 0;" at the end of callbacks.

You need to change that.

S. Eren BALCI
IMESTEK