LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set key focus to MCLB using propery node

Hi all,

 

I have a multicolumn listbox where I can open a dialog from when a key down/ double click or whatever event is fired.

The problem is that I lose the key focus and then the ability to navigate in the MCLB after the dialog is interacted with even when I am trying to set the focus back using "key focus" propery node.

 

I would like to get the key focus back to the MCLB so the user can continue navigating using keyboard arrows.

 

Is this a expected behavior?

 

Please have a look at my example below:

KeyFocus.png

Thank you in advance 🙂

0 Kudos
Message 1 of 8
(4,366 Views)

This works. But, should this be necessary?

WorkAround.png

0 Kudos
Message 2 of 8
(4,351 Views)

Well, this works too:

works.png

As long as you read a MCLB property before the dialog...

Why? Seems like a bug to me. 

0 Kudos
Message 3 of 8
(4,310 Views)

I would agree that it looks like a bug (and appears to work fine in older versions without the addition you added).


___________________
Try to take over the world!
0 Kudos
Message 4 of 8
(4,267 Views)

Looks like it's a matter of delaying - http://forums.ni.com/t5/LabVIEW/Key-focus-fails-as-window-frontmost-state-returns-slower-in/m-p/3230...


___________________
Try to take over the world!
0 Kudos
Message 5 of 8
(4,178 Views)

Hi,

 

I've been able to replicate this issue, and it is consistent when using any control on the front panel. The Key Focus property only works correctly when the Front Panel is the topmost window. If it is not in this state when the property node is called then it doesn't change the focus. What seems to be occuring is that the Dialog Box has not fully closed before attempting to set the property. I saw there were a few ways you have found to work around this, however they all achieve this by slowing the execution by having something occur between the Dialog Box and the property node. I was able to include a 1ms Wait during the execution and this allowed the Key Focus to return correctly.

 

One suggestion when you are using Key Focus, especially when opening and closing other windows is to force the VI Front Panel to be the frontmost window prior to calling the Key Focus property node.

 

I have also replicated the behaviour you are seeing when calling a property node before the Event Structure. This is strange, and I have forwarded this on for review in future LabVIEW versions.

 

Nic O
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 6 of 8
(4,097 Views)

NicO11 wrote:
"What seems to be occuring is that the Dialog Box has not fully closed before attempting to set the property."

 

Note that this behaviour is not exclusive to dialog boxes, it occurs with SubVI's as well. And it did not occur prior to LabVIEW 2014 (but is still there in 2015).

 

There is a solution in setting the frontmost-property yes, but then you have to discover (all occurences of the) the issue first. Subtle things that change unexpectedly like that just through conversion can easily go under the radar for some time.

0 Kudos
Message 7 of 8
(4,049 Views)

@NicO11 wrote:

 

One suggestion when you are using Key Focus, especially when opening and closing other windows is to force the VI Front Panel to be the frontmost window prior to calling the Key Focus property node.

 

 


I'm interested in highlighting 23 Boolean controls when they're in-focus by changing their background color and returning focus to the same control when returning from the subVI call.

 

The attached images show the check for FP.IsFrontmost=True, followed by a wait, and finally setting focus to the prior focus. Another while loop reads focus and creates Controls[] and focusArray; array size = 45.

 

I'm using LV2013SP1 Prof Dev System.

 

As far as the delay between occurrence of FP.frontmost = True and writing prior keyFocus states to the keyFocus property node, here are my results:

 

* 0 ms: focus returned 0% of the trials
* 1 ms: focus returned ~50% of the trials
* 2 ms: focus returned ~90% of the trials
* 5 ms: focus returned 100% of the trials

 

So, I set the wait time to 10 ms for now.

 

Not a critical feature but I would like to avoid complaints of inconsistent operation from the users.

 

Thanks,

 

 

Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 8 of 8
(3,785 Views)