11-22-2010 03:17 PM
I have a panel that has a Numeric control with a EVENT_LEFT_CLICK: that opens another panel.
When this second panel closes it updates the numeric on the first panel.
Up to this point everything works fine.
Now that the numeric has the focus on the first panel, to get the EVENT_LEFT_CLICK to fire the user has to double (and sometimes triple) click the control. I would like the user to be able to click once to fire the event (we are using a touch screen and it makes it more difficult) Its like the control is trying to help me select the value (it's highlighted).
I have tried to put the focus on another control so that when they click the numeric it will fire right away with no luck.
Any suggestions?
int CVICALLBACK UDOFFSET (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
float ctrlVal=0.0;
char msgBuffer[100]="\0";
switch (event)
{
case EVENT_LEFT_CLICK:
status = GetCtrlVal (panel, control, &ctrlVal);
// this is where I am setting the numeric with the value from the second panel that loads in the goCalc sub
status = SetCtrlVal (panel, control, goCalc(panel, control, ctrlVal)); //goCalc brings up second panel
status = InstallPopup(waitPH);
status = GetCtrlVal(panel, control, &ctrlVal);
status = RemovePopup(0);
break;
}
return 0;
}
11-22-2010 03:41 PM
I tested out the EVENT_LEFT_CLICK and it seems to work every time I click it.
However, You should not have RemovePopup(0); in the same section of code as InstallPopup as they will be called immediately after eachother. InstallPopup does not hang like MessagePopup.
Instead, have a callback function be called from your waitPH panel that gets the val and removes itself.
See \samples\userint\colview.cws
-- or --
this is done in the \samples\userint\clipbord.csv sample:
11-22-2010 06:54 PM
The function goCalc suspends the program with a loop - when it exits it updates the control in that same line then I remove the popup...
11-23-2010 01:43 AM - edited 11-23-2010 01:44 AM
int CVICALLBACK UDOFFSET (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){
float ctrlVal=0.0;
char msgBuffer[100]="\0";
switch (event)
{
case EVENT_LEFT_CLICK:status = GetCtrlVal (panel, control, &ctrlVal);
// this is where I am setting the numeric with the value from the second panel that loads in the goCalc sub
status = SetCtrlVal (panel, control, goCalc(panel, control, ctrlVal)); //goCalc brings up second panel
status = InstallPopup(waitPH);
status = GetCtrlVal(panel, control, &ctrlVal);
status = RemovePopup(0);
break;
}
return 0;
}
Wedge,
what's the meaning of the highlighted lines of code?
How is goCalc code? Can tou post it here?
Is that function returning a float? What's the return code from the line with goCalc?
11-23-2010 08:55 AM
Regarding your comment for goCalc, it should not displaypanel as that is what InstallPopup does.
I would something like this.
//callback for clicking button and okbutton on popup panel
int CVICALLBACK UDOFFSET (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
float ctrlVal;
switch (event)
{
case EVENT_LEFT_CLICK:
status = GetCtrlVal (panelHandle, PANEL_ABSOLUTEPANELNAME, &ctrlVal);
// this is where I am setting the numeric with the value from the second panel that loads in the goCalc sub
status = SetCtrlVal (waitPW, control,ctrlVal );
status = InstallPopup(waitPH);
break;
case EVENT_COMMIT:
if (panel == waitPH) { //OK button callback from popup panel
status = GetCtrlVal(waitPH, control, &ctrlVal);
RemovePopup(0);
if (!status) SetCtrlVal(panelHandle,PANEL_ABSOLUTECONTROLNAME,ctrlVal);
}
break;
}
return 0;
}
Sorry, may be typos in there and it is not optimized, but a general idea. i would recommend using the actual panel handles and controls in those functions as opposed to what is returned. Otherwise it can start to get confusing the more complicated your program gets or when you start assigning the same callback to multiple controls.