LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Confine mouse movement within boundary

Solved!
Go to solution

@Sable wrote:

Like this? (please refer to the attached vi done on LabVIEW 2013).


Looks good to me.

 

0xDEAD

0 Kudos
Message 11 of 20
(1,888 Views)

@Sable wrote:

Like this? (please refer to the attached vi done on LabVIEW 2013).


That's it!

 

I'd make a nice VI for it, maybe make the input rect -1,-1,-1,-1 default, and if the input is default call the null pointer. That way, you have one VI to set\remove the region. Two VI's works too of course.

 

You can put the clfn to "run in any thread". It's a tiny bit faster, as the clfn doesn't have to wait before execution.

0 Kudos
Message 12 of 20
(1,868 Views)

Could you please elaborate "You can put the clfn to "run in any thread". It's a tiny bit faster, as the clfn doesn't have to wait before execution."?

 

0 Kudos
Message 13 of 20
(1,857 Views)

My objective is to confine the cursor within the left pane of the front panel.

I am having some difficulty to do it with my vi. (please refer to the attachment done in LabVIEW 2013).

Can anyone please advise me what am I doing wrong?

 

- Sable

0 Kudos
Message 14 of 20
(1,850 Views)

You need to use the Method "Convert Pane to Panel Coords". Also, make sure that you close the pane references. There is probably still something wrong because I had to subtract 50 pixels from the Panel top position but otherwise it works as you want I think. I attached the VI in 2013 format.

 

ClipCursor by Pane (mod)_BD.png

Marc Dubois
0 Kudos
Message 15 of 20
(1,839 Views)

Concerning the "Run in any thread", you can configure the Call Library Function Node by right-clicking and selecting "Configure...". In the Function tab, you can select "Run in UI thread" or "Run in any thread". By default, "Run in UI thread" is selected.

 

If the dll needs to occupy a constant memory space (non-thread safe), you should use "Run in UI thread". Problem is that the UI thread is used for UI operations so it gets called all the time, so the dll call might have to wait for the UI thread to be available, and the dll call might also interrupts another UI operation. There is also the switch time between the current thread and the UI thread.

 

So when the dll is thread safe, it is better to use "Run in any thread". When the dll is called in the UI thread, the node header is orange and when "Run in any thread" is used, the node header is yellow (see below).

 

ClipCursor by Pane (mod)_BD.png

 

Marc Dubois
0 Kudos
Message 16 of 20
(1,828 Views)

Thank you very much Marc. Really appreciate thehelp.

 

I changed the clip cursor code a little to get it to work without the minus 50 pixels.

Let me know if this makes sense (please refer to the attached vi).

0 Kudos
Message 17 of 20
(1,810 Views)
Solution
Accepted by topic author Sable

It seems that you got it. You still need to close all the Pane references from the array, even if you don't use them.

Marc Dubois
0 Kudos
Message 18 of 20
(1,790 Views)

@MarcDub wrote:

It seems that you got it. You still need to close all the Pane references from the array, even if you don't use them.


Closing a Pane, or any descendant of the GObject class, does nothing and is unnecessary.

 

Reference from Darren Nattinger himself

0 Kudos
Message 19 of 20
(1,782 Views)

Thanks a lot for your solution - excellent! It helped me to move the mouse only in a sub-panel and not risk clicks outside of it. Within the sub-panel was a dynamically called vi. Thanks again, Peter

0 Kudos
Message 20 of 20
(1,592 Views)