LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

hovering activates command button

Solved!
Go to solution

I created a command button via the Create->Command Button menu option. It was working fine, but somewhere in my mucking around, I've gotten it so it acts as though it's pressed when I simply move the mouse key over it. I can't find an attribute that would cause this behavior. Can anyone help me with this?

 

Thanks.

0 Kudos
Message 1 of 18
(4,931 Views)

On what events are you reacting.... could it be that you changed the callback routine to trigger on GOT_FOCUS or LOST_FOCUS instead of EVENT_COMMIT?

0 Kudos
Message 2 of 18
(4,926 Views)

Most probably you have some code that is not tied to any event and so it's fired on EVENT_MOUSE_POINTER_MOVE events that are received by the control callback every time the pointer passes over it. Place a breackpoint inside the control callback and look at 'event' variable value, searching it in the list of events.



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 3 of 18
(4,925 Views)

Roberto -

 

You're definitely onto something. Event comes back as 33, which matches EVENT_MOUSE_POINTER_MOVE (I looked it up in userint.h).

 

When I first created this button, it wasn't doing that. I just checked my defaults, and it's not selected in there.

 

So...how do I correct this? I can't find anything when I edit the command button.

 

Thanks!

0 Kudos
Message 4 of 18
(4,901 Views)

It's not an option in control properties, it's how your code is structured:

 

int CVICALLBACK Impostazione (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	// This code is executed on any event. EVENT_MOUSE_POINTER_MOVE
	// is the most frequent one but not the only one
	DoSomething ();

	switch (event) {
		case EVENT_COMMIT:
			// This code is executed only when you press the button
			DoSomething ();
			break;
	}
	return 0;
}

 

The first DoSomething () is normally to be avoided...



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 5 of 18
(4,898 Views)

I see. Does the creation of automatic variables count as "doing something?" Because at this point, that's all I have up there.

0 Kudos
Message 6 of 18
(4,899 Views)

mzimmers,

 

Could we see the callback function code? That might help shed some light on the situation.

0 Kudos
Message 7 of 18
(4,899 Views)
int CVICALLBACK StartButtonCB (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	int		line, x, y;
	int		i;
	int		lockBusy;
	
	switch (event)
	{
		case EVENT_COMMIT:
			while (CmtGetLockEx(inUse, 0, 100, &lockBusy));	   // wait for lock in 100 ms durations.
			i = 0;
			while (sscanf(callbackData, "%d  %x  %x", &line, &x, &y) > 0 && (i < CONST_POINTS))
			{
				constArray[0][i] = x;
				constArray[1][i] = y;
				++i;
			}
			plot(i); 	// plot the points.
			CmtReleaseLock (inUse);
			break;
		case EVENT_RIGHT_CLICK:

			break;
	}
	return 0;
}

 

Thanks for looking.

0 Kudos
Message 8 of 18
(4,896 Views)

This callback responds only to commit and right-click events, so what lets you think the callback is "activated" while hovering the mouse on the button? How you detect this fact?

 



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 9 of 18
(4,889 Views)

I've just re-read the replies in this thread, and I think I know realize what was happening.

 

If I understand correctly now, the callback is executed on ANY event, not just the types specified in the callback routine, or the default types upon creation of the control?

 

I had a breakpoint at the top of my CB routine, and it was getting hit whenever I'd mouse-over the button. Hence, my confusion.

 

So...is there a way to program the object NOT to respond to a mouse-over, or is that just the way the package works?

 

Thank you all for the answers.

 

0 Kudos
Message 10 of 18
(4,884 Views)