10-19-2017 06:57 PM
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
10-19-2017 08:14 PM
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.
10-20-2017 06:31 AM
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...
10-20-2017 01:51 PM
@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.
10-20-2017 01:59 PM
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.
10-20-2017 02:55 PM
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.