Why hex input in number field does not work any more?

174 views
Skip to first unread message

YoungMin Kim

unread,
Apr 27, 2023, 10:46:30 PM4/27/23
to Blockly
If i remember correctly, i was able to input hex value such as 0xff in the number field but today i found i cannot. no input other than number is allowed. 

do you have any idea what happened?

YoungMin Kim

unread,
Apr 28, 2023, 12:26:17 AM4/28/23
to Blockly
i just found out it works on mobile browsers (chrome, safari) but not on any PC browsers (chrome, safari, firefox, edge)

2023년 4월 28일 금요일 오전 11시 46분 30초 UTC+9에 YoungMin Kim님이 작성:

Maribeth Bottorff

unread,
Apr 28, 2023, 3:57:09 PM4/28/23
to Blockly
Hello, thanks for posting.

I've asked the people who have been around the longest and they said hexadecimal input has never been officially supported. It did previously work.

We've had a longstanding feature request to get mobile browsers to show the numeric keyboard. In addressing that, we unintentionally forbade the browser from allowing any non-decimal input such as the `x` character. I've opened a change to fix this, however you should note:

- We don't officially support hexadecimal in the number field. It happens to work now but we don't make guarantees that it will continue to do so as this is not something we test for and actually were not aware worked.
- The current behavior works on mobile because the default mobile UI uses `window.prompt` instead of the HTML input. There is no way to restrict the input type of the prompt or hint to the browser to use the numeric keyboard. This behavior wasn't changed before and isn't changed with the PR I just opened.
- You can now disable the modal inputs on mobile if you prefer to use the native experience. If you do, then mobile browsers will show the numeric keyboard. On iOS the user can manually switch to the alpha keyboard, but on Android it does not show the keyboard switcher UI. So, if you disable modal inputs then even after this change you will not be able to type hexadecimal into the number field on Android only.

So if you want to explicitly allow hexadecimal input, and you want to disable the modal inputs on mobile, you may wish to consider creating a custom subclass of the number field that removes the `inputMode` attribute from the HTML input element. Otherwise, after the next main release this behavior will look more like the previous behavior.

Maribeth

YoungMin Kim

unread,
Apr 29, 2023, 10:09:16 AM4/29/23
to Blockly
Thanks for your help Maribetth. especially for openning the change.
It would be really helpful to me if hexademical input is supported (officially or not). because I have many custom byte manipulation blocks.


2023년 4월 29일 토요일 오전 4시 57분 9초 UTC+9에 mari...@google.com님이 작성:

ewpa...@gmail.com

unread,
May 2, 2023, 5:28:10 PM5/2/23
to Blockly
It's also possible to provide your own custom blocks to handle non-decimal representations. In App Inventor we have a number block that can specify from four bases: binary, octal, decimal, and hexadecimal, depending on what makes sense for the end user's needs. This is in addition to the standard number block, which we consider to always be decimal.

Cheers,
Evan

Reply all
Reply to author
Forward
0 new messages