From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

about limit the input characters in string with xcontrol

Solved!
Go to solution

Hi there,

  I follow one example online to deveope a xcontrol for string input but limiting the input characters only to uppercase A to Z. I have the main code shown as follow

 

aaa.png

 

In the Key down event, I discard all input character with ascii code beyond [65, 90]. This seems to works but if I keep pressing down a forbidden key (e.g. %), it will show that key in the control. So how can I ban the input by long press on one key? Thanks.

0 Kudos
Message 1 of 5
(3,077 Views)
Solution
Accepted by topic author dragondriver

Maybe you should try including a "key repeat?" event. This will handle the cases when a character is added when the user holds down the key. I believe that you will just need to copy all the code from the "key down?" event.

 

Jeremy P. 

 

 

Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(2,957 Views)

Or perhaps I should have suggested that you just add the "Key Repeat?" event to be handled by that case. You can have more than more event handled per case.

 

Jeremy P.

Applications Engineer
National Instruments
0 Kudos
Message 3 of 5
(2,954 Views)

@Prickly_Pear wrote:

Or perhaps I should have suggested that you just add the "Key Repeat?" event to be handled by that case. You can have more than more event handled per case.

 

Jeremy P.


Thanks. I didn't see there is Key Repeat before. I think that's what I am looking for. I will try that later.

0 Kudos
Message 4 of 5
(2,935 Views)

Hi dragondriver,

 

and while you're editing your VI you should use an InRangeAndCoerce function to replace two comparisons and a boolean function!

 

You might even think about using "LexicalClass", but that requires additional comparisons too...

 

#8000

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(2,929 Views)