LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Numeric Control = LEFT_CLICK problem

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;
}

0 Kudos
Message 1 of 5
(3,314 Views)

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:

 

InstallPopup (g_haboutPanel);
     GetUserEvent (1, 0, 0);
    RemovePopup (g_haboutPanel);
Although the latter would probably not work since the user can do manipulations on your popup panel.

 

0 Kudos
Message 2 of 5
(3,308 Views)

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... 

0 Kudos
Message 3 of 5
(3,302 Views)

 


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?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 5
(3,283 Views)

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.

0 Kudos
Message 5 of 5
(3,266 Views)