From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
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.
One 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.
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
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.
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
How do you make the "swallow event" work? Change the Control Mode to "Normal"
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.