I have designed a custom keyboard extension and I am able to enter text properly. However I can't seem to be able to figure out when to enable a capitalized keyboard and when lowercase. This is mostly because the following functions don't correctly return the already entered before/after text. Sometimes they will return nil, sometimes only a last few characters etc. Many times these methods are not even called at all.
- (void)textWillChange:(id<UITextInput>)textInput
- (void)textDidChange:(id<UITextInput>)textInput
I have figured out the following scenarios when I need to have enable my uppercase keyboard:
- Text length =0 or nil
- When a period is entered, I need to add a space and uppercase keyboard
- When the cursor is placed at a location where the character before cursor is either a period or a space and before that is a period.
- When user selected the entire text "Select All"
- When user selected the entire text and deleted all
- When user backspaces and the new character before cursor is either a period or a space and before that is a period.
- When user pastes text and the character before cursor is either a period or a space and before that is a period.
Also if the above is possible, is it possible to also get the last entered "entire" word which I can use for dictionary searches like for predictive typing?
I have read the apple document where it states that users expect auto-capitalization, so I am sure this should be possible