Search for darrens nugget on TRefTraverse (or was it on the blog: labviewartisan). This allows you to get all controls of an FP. Then you need to check the KeyFocus property (you will need to poll), and with the same refrence obtain the lable.
I figured out a way to get the control name by using a VI Server ref call and accessing the FindCtrlWithKeyFocus method, but now I'm having some other issues.
So I guess I need to go into what I am trying to accomplish. I want to be able to execute a command (via a FP run button or a User Menu event), and base my execution logic on the contol that previously had focus.
So my first problem is that as soon as I hit run or choose a menu selection the control I care about no longer has focus. So I need a Find "Previous" Control With Focus, which doesn't seem to be available. I can think of some ways to deal with this (like polling the current focus and keeping a rolling index), but none of them are easy and not really all that elegant.
The second and probably more importnant issue I'm seeing is if the control is inside an array, the FindCtrlWithKeyFocus method fails to locate a valid control. I want this to return the name of the array that had focus, but this doesn't seem to work.
I want to be able to execute a command (via a FP run button or a User Menu event), and base my execution logic on the contol that previously had focus.
Perhaps tracking the latest Mouse leave/up event may do the job (assuming your FP is maximized)
BUT, IMHO (as they say) I would look for a "state" to choose my command to run---- and by "state" I mean a distinguishable vector of values (not all values need be scalar) that are on Wires and execute the command defined by the vector. (I love Case structures I guess)
This sounds a bit vague- even to me. Can you provide more details at WHAT you want to elect to do and when the trigger point is?
I think we can offer solutions --- BUT you might wish to re-think your approach
It should be possible, however in a multitasking OS/UI the fokus will get lost or changed by accident...
So I would recommend a event stucture for keyboard/mouse events and keep that information in a (shifted) wire 😉
Also, Here is everything that I know of that deals directly with focus: