LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Clear a string control when Enter is pressed

Solved!
Go to solution

@Brandon.Baxter wrote:

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


That's a nice way to handle it, given the "revised" requirements.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 11 of 24
(1,443 Views)

I think we are dealing with a race condition and I would call it a bug. Note that things work fine if we are in execution highlighting mode or if we slightly delay the write to the local variable e.g. as follows:

 

ClearInput.png

 

(input is set to update while typing)

0 Kudos
Message 12 of 24
(1,432 Views)

It also seems to work properly if we use a value property node instead of the local variable to clear the string.

 

ClearInput2.png

0 Kudos
Message 13 of 24
(1,426 Views)

I didn't understand the problem either until I started messing with it. 

Using a reference updates the control.  I do have Update Value While Typing turned on.

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 14 of 24
(1,424 Views)

Here is a comparison of two seemingly functionally identical code version (one with a local, one with a value property).

 

Clearly some gears don't mesh correctly when using a local variable. This should work!

 

ClearInputComparison.png

0 Kudos
Message 15 of 24
(1,410 Views)

Yes, I know this isn't exactly what the Original Poster asked, but (a) this is much simpler, (b) this is trivial to understand, (c) this functionally does the same thing (though you could probably define an "edge" case where this wouldn't work), and (d) this also works if, instead of typing <CR>, you click outside the box to indicate you are done.  This (therefore) makes it much more intuitive for the User.  You do need to make the String Control a "Limit to Single Line" control, of course ...

Single String Input.png

 

 

 

 

 

 

 

 

Bob Schor

0 Kudos
Message 16 of 24
(1,396 Views)

Hello Bob I was toying with an idea similar to the one you presented.

 

The approach I'm going for is like text in an Instant messaging window. I.e. type stuff, enter, type more stuff enter. I started with the solution you posted but I found did not flow well having to click something arbitrary to trigger the value change event. The next thing I did was use a Send button rather than the value change to make it more intuitive to an end user. Ultimately I settled on pressing Enter to send the data to my consumer loop and clear the string because for this situation it is very Intuitive and it keeps the flow going to the end user.

0 Kudos
Message 17 of 24
(1,373 Views)

In that case, I would just set control to 'limit to single line' and use a 'Send' button that has a binding to the 'Enter' key.

0 Kudos
Message 18 of 24
(1,370 Views)

This is what I settled with. I would have liked to be able to do it without setting "Update Value While Typing". But other than that I'm very happy with the way the UI flows and the way this fits into my code.

 VI_PIC.PNG

0 Kudos
Message 19 of 24
(1,364 Views)

@Brandon.Baxter wrote:

Hello Bob I was toying with an idea similar to the one you presented.

 

The approach I'm going for is like text in an Instant messaging window. I.e. type stuff, enter, type more stuff enter. I started with the solution you posted but I found did not flow well having to click something arbitrary to trigger the value change event.


No, no, no!  Type <Enter> or "click something arbitrary".  I apologize for "telling you too much" -- I thought you'd realize that I was explaining a bonus property of my method, not only is it simpler, trivial to explain, and will do what you want when you hit "Enter", but if the User does decide to "click out", that will also work.

 

Oh, well.  Do it the hard way.  Good luck explaining the convoluted logic to someone else.

 

Bob Schor

0 Kudos
Message 20 of 24
(1,332 Views)