LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LEFT_CLICK_EVENT of Text Message Control

Hello,

I am trying to get the LEFT_CLICK_EVENT of a Text Message Control by using the GetUserEvent() function. For some reason I don't get any event for this control? Does someone know why? (I don't want to define or use a callback function)

Thanks.
0 Kudos
Message 1 of 4
(2,992 Views)
Hi Edgar,

If you look at the help for the GetUserEvent() function, you'll see it says:

"Obtains the next commit event or programmer-defined event from the GetUserEvent queue."

That means you won't be getting any events, since there are no COMMIT_EVENTs generated for the text message, and you are not using QueueUserEvent() to add any of your own events to the queue.

Using a control callback is really the only obvious way to get the left click event on a text control.  If you are dead set against using a callback, you can try to fake a text message using other controls that fire commit events.  For example, you can use a Command Button and just make the button color transparent.  This will generate a commit event that will be detected by GetUserEvent() when clicked, but it will look like a text message.  However, you may not like the fact that the label gets a box around it when the button gets the focus.  If that is a problem, you can use a Picture Button.  Again, make the button color transparent, delete the label, and for the picture, just create a text message with the text you want to display, copy it, then in the Edit Picture Button dialog, click the "Image..." button, and select "Paste Image".  Now the only real visible difference between this and a real text message is that when clicked, you'll see the text shift a little bit, since it is actually a button being pressed. Also, if the control is resized at run-time, the text will look pixelated, since it is a bitmap.

I hope this helps you get things looking/working the way you want.

Mert A.
National Instruments
0 Kudos
Message 2 of 4
(2,983 Views)
Using a transparent command button worked perfect.
 
Thanks Mert. 
0 Kudos
Message 3 of 4
(2,980 Views)

One word of caution:

When you click on a command button, you only receive a COMMIT event when you release the mouse button, not when you first press it. This is different from LEFT_CLICK events. And, more importantly, you only receive the COMMIT event if, when you release the mouse button, the pointer is still located over the button. Otherwise, there will no be event.

You can experiment with this in the User Interface Editor in operate mode, observing the events that arrive in the top-right corner of the window.

Luis
NI

0 Kudos
Message 4 of 4
(2,961 Views)