The title is a bit of a mouthful but it’s a very specific task that I’ve come across when making apps for iOS using AdobeAir. Often you want to tap in to some of the niceties of the operating system and one of those cases is the contextual keyboard – the specialised keyboards that appear when you’re entering in an email or a phone number for instance. There are 6 of these specified in the SoftKeyboardType class: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/SoftKeyboardType.html.
So the one thing to know when trying to use these keyboards on iOS is that you need to be using StageText – the standard TextField class will not be able to tap in to these as of yet because it’s really accessing an operating system level function that Adobe Air has not made available to the humble TextField. In that light, this quick tutorial explains how to go about using StageText to ultimately give you the option to use these different keyboard types. I’ve also included instructions on how to use customs fonts for this process too, just to complete the general use case requirements you may have.
<![CDATA[UIStatusBarStyle
UIAppFonts
BurbankSmall-Medium.otf
BurbankSmall-Bold.otf
]]>
You’ll probably have lots of other things inside your infoAdditions section as well. This is where I am wondering about if you need to have a relative path to your assets folder or not, so it might need to be entered as: Assets/BurbankSmall-Bold.otf but not sure. Will have to be some trial and error.
[Embed(source = "../bin/BurbankSmall-Medium.otf", fontName = "Burbank Small", mimeType = "application/x-font", advancedAntiAliasing = "true", embedAsCFF = "false")]
private var font_1:Class;
The fontName argument is important. You can actually make this anything you like for the sake of AS3 however when using StageText it seems to be working on an operating system level and the random name you give it for AS3 won’t mean anything, so it’s safest to use the fonts actual family name. This is really hard to find some times. It took a bit of trial and error and searching the internet to find that the family name for this file was “Burbank Small”. It looks like you specifically want to use the “Postscript Name” if you’re ever looking for the right one.
var myFont:Font = new font_1()
myStyle.font = myFont.fontName
myStageText:StageText = TextAir.convertToStageText(myTextField)
myStageText.softKeyboardType = SoftKeyboardType.EMAIL
Just a note – you might find that it works on the desktop and not on the device, this is usually because there’s something wrong with stage 2 – either it’s not been added to the infoAdditions properly, or the relative path you think should work, isn’t.