3

I want to handle a situation in my custom keyboard when the user moves the blinking cursor in the textview/textfield using my keyboard. I looked in to the apple's documentation of UIInputViewController and couldn't find any. Does anybody has an idea on how to do this?

P.S: This is a keyboard extension. In this we have KeyboardViewController which is subclass of UIInputViewController which implements "UITextInputDelegate". We have access to 4 delegate methods and none of them provides the required information. Is there any way to get information when cursor position changes:-

public func selectionWillChange(textInput: UITextInput?)
public func selectionDidChange(textInput: UITextInput?)
public func textWillChange(textInput: UITextInput?)
public func textDidChange(textInput: UITextInput?)
KrishnaCA
  • 5,615
  • 1
  • 21
  • 31
  • To my knowledge there is no delegates in UITextField or UITextView that would have this feature, or delegates to a UIInputView, short answer, no. – NSGangster Apr 27 '16 at 13:38
  • True , there are no such methods for that. but you can perform by creating custom methods by using touchesbegan and touchesEnded methods. – Sucharu Hasija Apr 27 '16 at 13:40
  • did fine this in docs `textField(_:shouldChangeCharactersInRange:replacementString:)` You could get the replacement string and the textField's shouldChangeCharactersInRange.startIndex to figure out where they tapped – NSGangster Apr 27 '16 at 13:41

0 Answers0