1

I have an NSTextView which has text replacement enabled and as expected it pops up suggestions as can be seen in the following:

Text suggestion popup

Question I have is - how do I detect that this is visible and how can I dismiss it programmatically. Simply setting first responder somewhere else doesn't do the trick. Indeed it ends the edit and leaves the popup still visible.

Thanks

Scotty
  • 2,019
  • 1
  • 20
  • 31
  • Seems similar to this: http://stackoverflow.com/questions/12217805/how-can-i-programmatically-dismiss-the-autocorrect-popover-in-a-uitextview – stevesliva Mar 30 '14 at 19:01
  • Thanks Steve. I'm on OSX and the suggestion there (unmarkText) doesn't have any effect. However, if I hack it by doing something like [self.textView.textStorage setAttributedString:self.textView.textStorage]; then it clears the popup. Not nice though - must be a better way? – Scotty Mar 30 '14 at 21:03
  • 1
    NSTextViewDelegate's textView:completions:forPartialWordRange:indexOfSelectedItem:and textViewDidChangeSelection: ?? Or maybe subclass textView and override complete: to just set a flag you can monitor? – stevesliva Mar 30 '14 at 23:42
  • I know this is an old post, but I am trying to figure out how to have text replacements appear in the suggestion box like that. When I create a toy app using a default NSTextView, text replacement is performed (e.g. `short` is converted to `long`), but it happens without displaying the popup. Typing slowly or quickly doesn't change this. Building TextEdit from source, however, does show the popups. But I can't identify the relevant code in TextEdit... Any pointers?? Thanks! – Fletcher T. Penney May 04 '18 at 16:09

0 Answers0