Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Keyboard extension with UITextField

I have custom keyboard extension with UITextField in it. I am able switch to UITextField's text input, but cannot switch back to self.textDocumentProxy. Does anybody know, how to do something like [self.textDocumentProxy becomeFirstResponder]?

(By the way, it looks like "GIF Keyboard" app provides such possibility)

like image 546
landonandrey Avatar asked Oct 19 '22 19:10

landonandrey


1 Answers

I've implemented next workaround for this:

  1. My textFied inherits from UITextField. UserInteraction disabled to prevent it from becomeFirstResponder (because you are not able switch back to system input). I've added blinking UIView as cursor imitation (blinking animation). Change this cursor origin.x in overwrited setText: method by calculating length of current string (use boundingRectWithSize: method for this).

  2. When user types something I am checking if textField is active (showed) and then adding/removing symbols to textField (with setText:) or self.textDocumentProxy insertText:/deleteBackward methods accordingly.

like image 131
landonandrey Avatar answered Nov 15 '22 03:11

landonandrey