LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Panel Events & Control Events - Priority?

I have a touch panel display with one button it... a Help button. If the user touches (clicks) the HELP button I want to display a Help info box. If the user touches anywhere on the screen, I want to move on to the next screen. However, when I click on the HELP button, a panel event is generated which seems to include all of the screen including the HELP button. THe panel event seems to take priority over the whole screen. How can I separate this into two events: button control event, and screen event?
0 Kudos
Message 1 of 6
(3,898 Views)
Hi Doug,

When a control callback is activated, it is initally called before the panel callback (at least in my experience). However, the panel left click event is called before the button commit event. Knowing this we can play the events off of each other. What you can do would be to create a global flag variable and use it to determine if the user clicked the help button or the panel. Since the help button callback is called first, you can set the flag to false which would tell the panel callback not to perform any actions. After the EVENT_COMMIt is performed on the button you can reset the flag back to true again in order to free the panel to move on. For example:

//Set your global flag
int moveToNextScreen = TRUE;

//The button callback
int CVICALLBACK ButtonCallback(int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
//Set our flag to false before any event takes place, to ensure it gets through before the panel event
moveToNextScreen = FALSE;
switch (event)
{
case EVENT_COMMIT:
/*Load your help file*/
moveToNextScreen = TRUE;
break;
}
}

//Panel callback
int CVICALLBACK PanelCallback(int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
switch (event)
{
case EVENT_LEFT_CLICK:
if ( moveToNextScreen == TRUE)
{
/*Move to your next panel*/;
}
break;
}
return 0;
}

Hope this helps!
0 Kudos
Message 2 of 6
(3,887 Views)
Thanks. Your suggestion works. I was surprised by the fact that a button on a panel would still invoke a panel event. I was thinking of the button as an "island" in the middle of the panel. I guess it makes sense however, since the panel is the parent, and the panel event gives notice that a click occurred somewhere on the panel. OK, now we got that straight... 🙂
0 Kudos
Message 3 of 6
(3,880 Views)
You're very welcome, I just help out for the free lunch offers 🙂

http://forums.ni.com/ni/board/message?board.id=180&message.id=15653
0 Kudos
Message 4 of 6
(3,872 Views)
Hmmm... I guess I now owe you two lunches in Vegas.
0 Kudos
Message 5 of 6
(3,859 Views)
You may want to be careful about EVENT_LOST_FOCUS for your Help button. If you set the global on any callback, EVENT_LOST_FOCUS (occurs when the focus moves to a different control) may cause some unintended results. You may want to test if (event != EVENT_LOST_FOCUS) before setting your global.
Will you have a Back button to return to a previous screen? Users may run into trouble trying to click on Help and missing or by clicking on the window to return to it from another application.
0 Kudos
Message 6 of 6
(3,850 Views)