0

We can use deleteBackward in TextDocumentProxy to delete a last letter.

Now i need to delete a letter of last letter.

Eg. Apple , i want to delete l letter before e.

How can i do it?

Fire Fist
  • 7,032
  • 12
  • 63
  • 109

2 Answers2

1

Get the last character from the documentContextBeforeInput, delete twice, and add the character as text.

If you feel this API is lacking, make sure to open a bug report and/or an enhancement report with Apple.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
0

Here what I did... Its not perfect but good for a now to delete last word. You might found it useful.

-(void) removeLastWordFromInput{
    for (int i = self.textDocumentProxy.documentContextBeforeInput.length - 1;i > 0; i--) {
        if ([self.textDocumentProxy.documentContextBeforeInput characterAtIndex:i] == ' ')
            return;

        //delete last character
        [self.textDocumentProxy deleteBackward];
    }
}
Leo Moon85
  • 150
  • 10