开发者

Apple iOS: Howto sent 'Eject Key' to the text input system

I have made an app which uses a bluetooth barcode scanner. When the barcode scanner is attached, the on screen keyboard will not come up anymore. Therefore I cannot use the on screen keyboard for text input. It is not very handy to do text input through barcodes (as I want to input very variable data) so I am looking for a way to present the on screen keyboard although an external keyboard is attached. The Apple wireless keyboard achieves that by sending the eject key to the iPad.

I have found on the internet that the eject key is keycode 161. I can make an NSString with the eject key as follows:

// Put the eject key Unicode U+23CF in a NSString. Two different ways possible:
NSString *eject = [NSString stringWithFormat:@"%C", 0x23CF];
NSString *eject2 = [NSString stringWithUTF8String:"\u23CF"];

When looking at the debugger, both NSStrings show an eject icon开发者_如何学C as the contents of the NSString so it seems I am having the code right to fill the NSString with the eject button. But my problem is, how do I send this NSString to the keyboard input system in order to trigger the on screen keyboard to pop up? I cannot sent it by making a barcode with the contents "\u23CF" is it is not recognized as a UTF8 string. Setting the text of a UITextField (either with or without the return key) doesn't do the job either.

Can anybody help me with this problem? Am I missing something? To my knowledge the only control Apple gives us over the on screen keyboard is with becomeFirstResponder and resignFirstResponder but that's useless when an external keyboard (or scanner) is attached.


We're looking into the same thing. Perhaps one of these links might help you find an answer.

Code 128 seems to allow you to send ASCII characters, normally these are not printable. http://en.wikipedia.org/wiki/Code_128

Here's an article where a library is used to create UTF-8 barcodes but unfortunately they don't give a sample of the image. Perhaps the code will be enough to give you an idea: http://www.aspose.com/docs/display/barcodenet/How+to+Generate+and+Recognize+BarCodes+for+UTF+8+%28Unicode%29+Characters

Here was my original find. While it's for another piece of software the guy uses Code 128 to send a Ctrl-B character: http://www.psoft.com.au/baslogue/help/person/setting_up_scanner.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜