08-18-2017 10:55 AM
My goal is to be able to type into a string control and then press the enter key on the keyboard to "execute" what I typed and clear the control. This seemed like a no-brainer and I wrote the code below:
The other case is simply default and nothing happens. To my surprise I cannot clear the control in this way, I have also tried invoking the reinitialize to default method. I only seem to be able to clear the string with either of those options outside the while loop.
Shouldn't this work? I feel like I'm missing something simple because it's such a straightforward paradigm.
I have attached my code below. I would love to hear any suggestion and to know why this doesn't work.
Thank you in advance
Solved! Go to Solution.
08-18-2017 11:07 AM
Have your case structure handle the "Return" and "Enter" keys in the same case. They are separate keys and register differently.
08-18-2017 11:12 AM - edited 08-18-2017 11:14 AM
Thank you, good catch. I have an indicator showing me that the "Return" case was executing as expected but the string did not clear. As added assurance, I checked the case "Return","Enter" and got the same results. Any Ideas?
08-18-2017 11:17 AM
Just played around some more and I think I understand the problem now. The problem is that the value stored in the input is not really updated until after the Key Down event. So your writing to the local variable is being overridden but the underlying code that detects the value change. You can see this more clearly if you add an indicator inside of the event case to show what the input value is when that event case is called.
The workaround I found was to set the input control to "update value while typing".
08-18-2017 11:17 AM - edited 08-18-2017 11:19 AM
Set string control to 'Limit to Single Line'
EDIT: Nevermind. Not consistent.
08-18-2017 11:22 AM
@crossrulz wrote:
The workaround I found was to set the input control to "update value while typing".
I could only get it to work using both 'Update Value While Typing' and ' Limit to Single Line' together
08-18-2017 11:25 AM
oh, that's tricky. At first I was using a the notify "key down?" event and thought was getting over written which is why I switched to the "Key Down" event instead. do you think this would be classed as unintentional behavior?
Also thank you for the workaround, it even works for the "key down?" event
08-18-2017 11:27 AM - edited 08-18-2017 11:33 AM
i think i missed the original point of the discussion and my idea leads to the same issues.
08-18-2017 11:31 AM
Hello Bill, I like the "Key Down?" event because you can discard the character an append whatever you want as an end, like a sync word for example
08-18-2017 11:35 AM
@Brandon.Baxter wrote:
do you think this would be classed as unintentional behavior?
I would not. I would be tempted to call it a documentation issue. But I have not dived into the LabVIEW help to see if this order of event execution is anywhere in there. If not, definitely an issue.