10-03-2012 03:08 PM - edited 10-03-2012 03:09 PM
I am trying to flush out my scripting code - and one of the functions that I have made automatic is pulling the focus from newly dropped controls/indicators LABEL on the FP - I want to be able to select the text of the Label - and I thought it was possible with VI Server Label.Selection. I am using another VI to take the VI Ref of the VI I am monitoring to get the last placed Control on the FP using the Traverse Scripting function - that part is working great.
Label.Selection is not working, even when I immediately set KeyFocus= TRUE before the Label.Selection property. I have even inserted a VIFrontPanel.IsForemost setting it TRUE for the target VI before requesting the KeyFocus for the control...
I have verified that the target VI is IDLE by reading the state of the VI.
GOAL: I am trying to mimic the selection of the entire label that happens when you drop a new control.
Any insight would be appreciated. I have posted on the Scripting Board - but not gotten any response.
Solved! Go to Solution.
10-03-2012 05:02 PM
On my Windows machine I would probably resort to a little mouse function trickery using user32.dll.
Here I simply select the first control, put the cursor in the center of the label and fake a double click. Then I move the cursor to the bottom right.
10-04-2012 08:31 AM
Great, I will try that - maybe I will just fake the triple click that selects the whole label and see if that works.
Thanks for the suggestion! Other VI Server functions just were not getting me there - must be something weird with the KetFocus, as others have noted in the past that it does not work in some instances.
I will report back if it works out for me.
10-04-2012 09:04 AM - edited 10-04-2012 09:04 AM
Darin - Brilliant!
Modifying the code to use a triple click worked like a charm, can cut out the functions after then For Loop
10-04-2012 12:40 PM
Now I am wondering about how to convert BD coordinates to screen coordinates to adapt the same code for if the BD was the activated screen originally. The same nice functions do not exist for converting BD locations to Screen Coordinates that I am aware.
10-04-2012 01:14 PM
There may be a better way, but I usually do this. The constant offset works for me, you may need to double check, and you may want to verify that you will be clicking inside the window (ie. the selected object may be off screen).
10-04-2012 01:59 PM - edited 10-04-2012 02:10 PM
You are a mouse position manipulating madman - I love it.
I will double check - as the label.selection function again does not work even when I feed it the ControlTerminal reference output from my BD Traverse. Very disappointed in this scripting property - would be so elegant if it worked as touted in the LabVIEW Help.
I can easily use the BD ControlTerminal Traverse, then use the output ref and get the GObject REF I need, change to more specific class to ControlTerminal, then use the CtlTerm property of Label.TotalRect to replace the Gobj TotalRect to make sure I am only clicking on the Control Terminal's owned label. The object will not be off the screen in this instance since I am writing the code to detect when the object is created on the BD as the BD is activated. If it was the FP that was activated then the previously created code you helped me with will be the subVI called.
10-04-2012 02:27 PM
Combining with your mouse positioning and changing from double click to triple click did the trick. Selects the Control Terminal Label - thanks!