06-24-2014 09:37 AM
Referring to this post, I am trying to update a control based on numeric data being entered into a numeric control, using the EVENT_KEYPRESS event. I am attempting to ignore non-numeric entered data (including virtual key codes). Using the following code, I get consistent lockups of CVI 2013:
int temp1, temp2; case EVENT_KEYPRESS: temp = GetKeyPressEventVirtualKey(eventData2); if (temp == 0) temp = isdigit(eventData1); else return -1; break;
As you can see, I even tried swallowing future events. I can set a breakpoint in this event and pass numeric data just fine. But then when I hit a non-numeric virtual key (Home, F4, etc), after the GetKeyPressEventVirtualKey, my debugger locks up hard and is unrecoverable.
Is this a CVI bug?
06-25-2014 06:29 PM - edited 06-25-2014 06:29 PM
Hi ElectroLund,
I can't find any bug report on this. However, I'm still looking into it for you.
Corey C
Applications Engineer
National Instruments
06-26-2014 02:45 AM
@coreyc wrote:
Hi ElectroLund,
I can't find any bug report on this. However, I'm still looking into it for you.
Corey C
Applications Engineer
National Instruments
Are you filing a new car?
06-27-2014 12:29 PM
Hey ElectroLund,
Could you post the simpliest version of your code. I've used your snippet on CVI 2013 and got a fatal runtime.
Corey C
Applications Engineer
National Instruments
07-09-2014 05:00 PM - edited 07-09-2014 05:00 PM
Just adding that there is an article in the help manual about event swallowing:
LabWindows/CVI 2012 Help: Swallowing Events
This article is basically the same in the LabWindows/CVI 2013 SP1 Help Manual (which I have installed on my computer). I would try making a simple project where the only code is main function and one callback to swallow keypress events and the only thing that event does is return 1. For troubleshooting, it's best to start simple and build up to find the problem.
07-09-2014 05:14 PM - edited 07-09-2014 05:21 PM
I just tried out some simple code, and it appears to be swallowing events without locking up. Is the lock up perhaps when you're swalling an event like exitting out of the panel so that you can no longer click out of the panel?
My Code:
int CVICALLBACK ProcessEvents(int panel, int event, void *callbackData, int eventData1, int eventData2)
// ProcessEvents is the callback for my panel in the UIR file
{
int keyEvent = 0;
switch (event) {
case EVENT_LEFT_CLICK :
SetCtrlVal (panelHandle, PANEL_EVENT, "left click");
break;
case EVENT_KEYPRESS :
//Keycheck (eventData1);
keyEvent = 1;
break;
}
if(keyEvent == 0)
return(0);
else
return 1;
}
07-10-2014 08:13 AM
Good questions/thoughts, TBirkulosis. When I get some more time to return to this project, I will test.
But in general, you are very correct. I owe it to myself to start more simple, rather than blindly swallow events and "hope for the best."
Cheers