From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

programmatically select the text in a case structure "selector label"

I have done some vi scripting in a plugin I created to move or copy multiple selected items from one case of a case structure to another. One option for the target case is to create a new one. I have this all working adequately where it adds the new case and puts the appropriate items in it. I would like if in this instance it would behave the same as the "duplicate case" method where at the end the text in the case structure selector label (the part across the top where the conditions for the given case are listed) would be selected entirely. I cannot seem to find any property nodes, references, or methods that point me to that item. Is there a way to get its reference or another way to make it active and its text selected? 

I know that I can change the text in that field via the Frame Names property but that is not quite what I am looking for.

Thanks

0 Kudos
Message 1 of 11
(1,495 Views)

@tshurtz wrote:

I have done some vi scripting in a plugin I created to move or copy multiple selected items from one case of a case structure to another. One option for the target case is to create a new one. I have this all working adequately where it adds the new case and puts the appropriate items in it. I would like if in this instance it would behave the same as the "duplicate case" method where at the end the text in the case structure selector label (the part across the top where the conditions for the given case are listed) would be selected entirely. I cannot seem to find any property nodes, references, or methods that point me to that item. Is there a way to get its reference or another way to make it active and its text selected? 

I know that I can change the text in that field via the Frame Names property but that is not quite what I am looking for.

Thanks


Looks like that's not possible.  Some things are simply not accessible programmatically.  Other examples are the text in a variant control, and the colors of the bezel on classic controls.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 11
(1,436 Views)

I also do not see any way to get the reference of the frame selector and programmatically highlight it. If this is something you really want done, then this is what I would try...

 

1. Get the current coordinates of your mouse on screen

2. Get the coordinates of the very center of the frame selector (I feel like this should be doable somehow or another)

3. Programmatically move mouse cursor to that position

4. Programmatically double or maybe even triple click just to be sure you've highlighted everything

5. Programmatically move mouse cursor back to initial coordinates

 

It's dirty, but it might just be the only way.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 3 of 11
(1,434 Views)

@FireFist-Redhawk wrote:

I also do not see any way to get the reference of the frame selector and programmatically highlight it. If this is something you really want done, then this is what I would try...

 

1. Get the current coordinates of your mouse on screen

2. Get the coordinates of the very center of the frame selector (I feel like this should be doable somehow or another)

3. Programmatically move mouse cursor to that position

4. Programmatically double or maybe even triple click just to be sure you've highlighted everything

5. Programmatically move mouse cursor back to initial coordinates

 

It's dirty, but it might just be the only way.


f.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 11
(1,415 Views)

@paul_cardinale wrote:


f.png


I thought that was a good bet too, but the coordinates that gives isn't the actual on-screen coordinates of the frame selector. Seems like it gives the coordinates of the selector in terms of some 0 point of the block diagram. Would probably need it to get to to the on-screen coordinates though.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 5 of 11
(1,411 Views)

I had thought of the triple mouse click option but was hoping for a better way.

 

I got a vi working that would click in the right place given the reference to the case structure and it highlighted the text correctly but had problems when including in my plugin. 

 

A few notes on the position for those who might be interested.

I couldn't directly find the screen position of the block diagram so I had to get a bit creative. I used 

Block Diagram Window : Window Bounds (which gives you corners of window not the block diagram itself.) and added

Front Panel Window : Panel Bounds minus Front Panel Window : Window Bounds (effectively the negative widths of the window title bar, scroll bars, etc assuming they are the same on the front panel and block diagram) (I couldn't find a property node for the block diagram bounds in the same way the front panel has)

I use Left and Top from these results added to Horizontal and Vertical from Block Diagram Window : Origin (to account for the scrolling that may have happened on the block diagram) and (Left+Right)/2 and (Top+Bottom)/2 from FrameSelector Rect property of the case structure.

 

This worked great in my testing but...

when I implemented into my plugin it stopped working (if I don't move the mouse back it does end up in the right place so it isn't the positioning that is the problem).

It is like the mouse clicks that happen during the plugin are ignored. Is that expected behavior?

Thanks again

 

0 Kudos
Message 6 of 11
(1,389 Views)

@tshurtz wrote:

I had thought of the triple mouse click option but was hoping for a better way.

 

I got a vi working that would click in the right place given the reference to the case structure and it highlighted the text correctly but had problems when including in my plugin. 

 

A few notes on the position for those who might be interested.

I couldn't directly find the screen position of the block diagram so I had to get a bit creative. I used 

Block Diagram Window : Window Bounds (which gives you corners of window not the block diagram itself.) and added

Front Panel Window : Panel Bounds minus Front Panel Window : Window Bounds (effectively the negative widths of the window title bar, scroll bars, etc assuming they are the same on the front panel and block diagram) (I couldn't find a property node for the block diagram bounds in the same way the front panel has)

I use Left and Top from these results added to Horizontal and Vertical from Block Diagram Window : Origin (to account for the scrolling that may have happened on the block diagram) and (Left+Right)/2 and (Top+Bottom)/2 from FrameSelector Rect property of the case structure.

 

This worked great in my testing but...

when I implemented into my plugin it stopped working (if I don't move the mouse back it does end up in the right place so it isn't the positioning that is the problem).

It is like the mouse clicks that happen during the plugin are ignored. Is that expected behavior?

Thanks again

 


bdb.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 11
(1,383 Views)

@paul_cardinale

Thanks, but Block Diagram Visible bounds is the width and height of the BD and not its location on the screen (like Front Panel Window : Panel Bounds is) so not really useful to me in this case.

 

But that's not my problem at this point. Now its the discarded mouse events (or perhaps a new auto selection) that happen when I run the VI as a plugin.

0 Kudos
Message 8 of 11
(1,365 Views)

I just tried a new plugin where I just move mouse inside upper left of the DB window a ways then mouse down, move to just inside the lower right corner and mouse up. In a non plugin version this effectively selects everything on the BD as I would expect it to. In the plugin version however I can see the mouse move but nothing is selected.

I even waited a little while and then reported the size of the BD selection list to a popup before exiting plugin. It said 0 so it is not selecting (as opposed to throwing the selection away as it exits).

Additionally I can see the selection box being drawn in the non plugin version but not in the plugin version.

 

Should I start a new thread with that as the topic at this point?

0 Kudos
Message 9 of 11
(1,361 Views)

How are you doing your mouse clicks? Call Library Function Nodes to user32.dll?

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 10 of 11
(1,307 Views)