Is there a way to force the ios keyboard into the numeric mode when a user gives focus to a text entry field?
Not at present, though as far as I know the new Form component in 8.3 has modes that hint to the underlying OS appropriately to show the 'correct' keyboard. a quick look at the manual suggests this hasn't (yet?) landed
It’s possible to do this but the method is a bit hacky, and I haven’t looked into it enough to see if there are any big drawbacks.
You can create a Markdown component with escapeHtml: false
and source: <input type=”tel”>
, then give it an event script for onKeyDown
that looks something like this:
def runAction(self, event):
if event.keyCode == 8:
self.view.custom.numbers = self.view.custom.numbers[:-1]
elif event.keyCode in range(48, 58):
self.view.custom.numbers += event.key
In this example I’m writing to a custom property I made to store the input, since input with the Markdown component is weird (and probably not intended to be a thing). You would have to tweak this to work better with your constraints and be sure to sanitize the input.
Honestly, I would probably recommend against doing this, but I thought it would be fun to share.