LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
LJHerskowitz

For position property, choose the origin

Status: Already Implemented
Use the "Convert Pane To Panel Coords" and "Convert Panel To Pane Coords" methods of the Pane class

Every so often I want to pop up a VI at my mouse location when I click a control. The annoying part is the coordinate system from the event structure is relative to the pane. The position property node is relative to the front panel window. But I need coordinates relative to the screen. It is doable to get the appropriate coordinate system but it would be faster if you can just choose which origin you want (pane, front panel, screen).

 

I thought it could be an input on the property nodes like in the image below. The input can be an enum with the appropriate options.

Position Origin.png

9 Comments
altenbach
Knight of NI

Since property nodes execute top to bottom, you probably want to reverse the order in your picture (origin on top, position below)

LJHerskowitz
Member

Thanks

 

Position Origin.png

AristosQueue (NI)
NI Employee (retired)

That's not going to work -- introducing a state on the control would break all other scripts that tried to read your property and were expecting the current coordinate system.

 

It could, however, be a new method "Position Given This Origin", which takes the origin as an input parameter.

LJHerskowitz
Member

You are right. I hadn't given the property node solution much thought to be honest with you. I guess I figured it could work like the plots on the XYGraph.


I also don't know if there is a fantastic solution for the events in the event structure that give mouse coordinates. It might have to be some sub.vi to transform coorindate systems.

ouadji
Trusted Enthusiast

LJHerskowitz :

 

The annoying part is the coordinate system from the event structure is relative to the pane.
The position property node is relative to the front panel window.

But I need coordinates relative to the screen.

 

You're absolutely right. It's very annoying, kudos.

 

tst
Knight of NI Knight of NI
Knight of NI

I'm pretty sure LV already has methods for converting between coordinate systems (at least pane to panel and possibly global). I don't remember where they are for sure (possibly Application, VI, Panel or Pane), and I can't look at the moment. If there isn't one for global coords, it probably just needs to be added there.


___________________
Try to take over the world!
AristosQueue (NI)
NI Employee (retired)

tst: Ah... yes... forgot about those. Good reminder.

 

On the Pane class, there are two methods:

Convert Pane To Panel Coords

and

Convert Panel To Pane Coords

 

LJHerskowitz: do these solve your problem?

 

For everyone else: A reminder that ctrl+shift+B will bring up the Class Browser which lets you search for properties/methods by name.

LJHerskowitz
Member

Thanks AristosQueue,

Yeah that sounds like exactly what I wanted.

 

Darren
Proven Zealot
Status changed to: Already Implemented
Use the "Convert Pane To Panel Coords" and "Convert Panel To Pane Coords" methods of the Pane class