02-05-2011 07:21 AM
Hello all!
I'm having troubles with GetRelativeMouseState(). Somewhy left\right remains 0 and cause my program not to work.
Why is it happening?
If anyone can write how this command works, it can also help me.
int CVICALLBACK start (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetRelativeMouseState (panel, control, NULL, NULL, &left, &right, NULL);
SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1);
controlnum=control;
break;
}
return 0;
}
Thanks!
02-05-2011 11:35 AM
Hi!
In such cases a good idea is to try the examples provided with CVI to check if and how these are working. In this case, you can have a look at userint\moustate.cws
In general, you may use the example finder in the menu Help / Find Examples. For this particular case, typing mouse in the search field will return the above result.
You may try it and compare the code with yours.
Good luck!
02-05-2011 12:44 PM
Thank you for answering!
I tried it already - no success. I searched in "canvas.cws" and "mousestate.cws" and didnt find an answer.. 😞
Thanks anyway!
02-05-2011 12:53 PM - edited 02-05-2011 12:54 PM
I never tried to use the function in a similar way as yours, but some general rule may apply. In a windows environment a button commit event is fired when your release the button, so I'd expect to receive '0' as 'left button pressed'. Similarly, it's not clear to me how you can fire a commit event with a mouse right click.
Could trapping EVENT_LEFT_CLICK and EVENT_RIGHT_CLICK events instead of commit event help you solving your problems?
02-05-2011 01:23 PM
Unfortunately not.
I'm writting a program that simulates Minesweeper and GetRelativeMouseState is the only command in which I can trap clicking both left\right simultaneously.
If you have some other ideas, I'll be glad to hear!
Thank you!
02-05-2011 01:58 PM
hm..., so why don't you skip the case event and check if left and right are true? Something like
int CVICALLBACK start (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
GetRelativeMouseState (panel, control, NULL, NULL, &left, &right, NULL);
if ( left && right )
{
SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1);
controlnum=control;
}
return 0;
}
02-05-2011 02:04 PM
I also tried it.
left\right are static int in the main and according to them the program knows if the specific control (cell) should be revealed, been flaged or to expose every control around it. The only problem is that i just cant make this command work properly 😞
02-06-2011 11:05 AM
Progress: after checking my program I can say with confidence that the function work!
But, in order it to work, the click on the button should be lonnnggggggggg......... why is that?
I searched over the net and didnt find answers..
Thank you!
02-07-2011 02:20 AM - edited 02-07-2011 02:21 AM
Hi ehud83,
I made up a little project to test a different approach (trapping EVENT_LEFT_CLICK / EVENT_RIGHT_CLICK): on my machine I have no need to press the buttons for a long time. Instead, I noticed that trapping the mouse clicks heavily depends on mouse settings in control panel; specifically, the double-click speed determines how two subsequent mouse clicks are interpreted: if the double click speed setting is low (as it was on my laptop) you cannot discriminate two fast clicks as left clicks (the system sends a click + a double click event); reducing that mouse setting permits you to discriminate individual clicks faster.
In the project I also tested how to use that system on controls different from command buttons (specifically some text messages) using a panel callback.