Data Validation

In a Bluetooth terminal app, I need to restrict the data input to a textBox to Hexadecimal only. I.e the TextBox should take Hex data only and ignore other key presses. Is there a way to do this?

Use the "is number?" block and change the type to hexadecimal in the dropdown. It will return true if the value is Hexadecimal or else false.

Send the data to hex

Can App Inventor send hex raw data to a Bluetooth device?

Send hex code via Bluetooth module

Try checking these links

Hi Mayank, Thanks a lot for your response. Actually what I want is not to check the data type, but restrict the entry to the textBox by the user to Hex only. The app will be sending serial data via Bluetooth. I am trying to set up an option for the user to select between ASCII and Hex. Once the user opts for Hex, then the text box should accept Hex data only and should not respond otherwise. For example, if ‘ASDFHJ 10’ is entered, the text box should display AD-F1-0.

1 Like

It might be difficult to do this way, I am unsure but there is a way to filter out only a particular type. I am sharing it in a minute.

OR

Modify the code if needed. :slightly_smiling_face:

Great, let me tinker with these methods, though it seems to be a way too long.

1 Like

Hi @Raja_Sankaran
There is a simple way of restricting the input to hexadecimal values -
image

I have already suggested that but he wants to do it from a mixed string.

Here you go, all draggable blocks -

blocks (13)


blocks (11)

And the result

image

I hope this is what you wanted

This is can do the job I think. Thanks a lot.

You are welcome!! :+1: :+1:

This is kinda late and overkill compared to @Alaqmar_Bohori 's solution,
but intended for people who want complete control over their keyboard and need multiple input fields.

The only component I could find that I could both click for focus and gain complete control over was a button. In practice, initialize the button texts to their prompts, and click the buttons to give them focus and pop up the hex keyboard with a global variable set with that button's component for the keyboard's sake.

I use a '|' as a cursor. A Clock could be used to blink it, if you like, but I didn't see the need for it.

To copy this into your app, copy the Vertical Arrangement holding the keyboard (ctrl-C) and paste it (Ctrl-V) into your Designer.

All blocks shown here are draggable.
hex_input.aia (9.1 KB)
Capture Cursor movement
Start Edit


activeHexTextButton