LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Key Down? Event discard not working

I'm having an odd issue in LV2016 where if I use the Key Down? event on a string, the discard function does not work consistently. If I mouse into the string control and press a key too quickly after clicking in, even though the event triggers, the string control does not get updated. I've attached a VI where the discard? input is hard coded to False, but I can still consistently get a situation where keys are still getting discarded.

 

(The reason this matters is I have a separate VI where there is a large number of text boxes and if I enter values too quickly when going between boxes, I get inconsistent keyboard input)

 

Any help is appreciated,

-Alex

0 Kudos
Message 1 of 6
(3,153 Views)

I think I see what you mean, but I have to be extremely fast on the key down for that to happen.  I think it is so fast that I'm hitting the key down before the up click of the mouse to enter the field  So there is a race condition that you really aren't in the field yet until the mouse up completes.

 

Is that what you are seeing?  How fast are you doing things that you discovered this problem?  If I'm fast, but not superfast, the control behaves like I'd expect.

0 Kudos
Message 2 of 6
(3,131 Views)

This is weird and seems like a bug to me.

 

The event does report the char you're clicking. So the control much have key focus. It seems the event structure reacts to the key down before the control does. So you get an event, but the key down is discarded anyway. Also you don't get this behaviour with Key Down event, or without an event. So the Key Down? event must somehow cause this.

 

When I add a Mouse Down? event, I can see the time between mouse and key is up to 110 ms, but no character. Sound like an eternity for a CPU.

 

Can't find any workaround either...

0 Kudos
Message 3 of 6
(3,103 Views)

@RavensFan wrote:

I think I see what you mean, but I have to be extremely fast on the key down for that to happen...

 

Is that what you are seeing?  How fast are you doing things that you discovered this problem?  If I'm fast, but not superfast, the control behaves like I'd expect.


I've observed something similar to what you were. In most cases I'm not quick enough to get this circumstance to happen during normal use, but when I intentionally try to cause the bug to happen it is consistently repeatable.

 

0 Kudos
Message 4 of 6
(3,067 Views)

wiebe@CARYA wrote:

This is weird and seems like a bug to me.

 

The event does report the char you're clicking. So the control much have key focus. It seems the event structure reacts to the key down before the control does. So you get an event, but the key down is discarded anyway. Also you don't get this behaviour with Key Down event, or without an event. So the Key Down? event must somehow cause this.

 

When I add a Mouse Down? event, I can see the time between mouse and key is up to 110 ms, but no character. Sound like an eternity for a CPU.

 

Can't find any workaround either...


I have also observed that the Key Down event does not get this behaviour. Additionally, if I probe the event information of the Key Down? event, the CtlRef is the correct string control and it is seeing the correct character Char, which leads me to believe that the event is firing correctly, but something weird is happening that causes the character to be discarded.

0 Kudos
Message 5 of 6
(3,063 Views)

Definitely strange. If you look at the event inspector window it will actually tell you whether or not the event is being discarded. In your test VI though, even when it is being discarded the event inspector window will not log that.

 

You don't even have to move so quickly if you actually just click and hold the mouse down in the string field and try to enter in a key. If you do this, you will see the mouse either flicker or go from the pointer to text style. This point seems to mark the working and non-working cutoff. If you press the key before that flicker it will be discarded, if you enter it in after the flicker it will not be.

Matt J | National Instruments | CLA
0 Kudos
Message 6 of 6
(3,053 Views)