1

My Cocoa application uses NSTextView. It is sort of an editor application. Now in 10.6 there is character substitution so (c) becomes copyright. My application was not doing the substitution in 10.6. And I did not add any additional code for that. But in 10.7 the substitution is taking place. This is causing confusion to clients who have just migrated to lion. I know that I can write an applescript to disable the checkbox in language and text. But is there any other option ?. I also tried defaults write -g WebAutomaticDashSubstitutionEnabled -bool false.

but this also did not work.

Prashant
  • 2,190
  • 4
  • 33
  • 64
  • 1
    This is a dupe of http://stackoverflow.com/questions/8144784/turn-off-os-x-10-7-lions-auto-correct-feature-programmatically which has your answer. – James Williams Dec 10 '11 at 01:35
  • @JamesWilliams: No, it is not a duplicate of that question. That question is asking about auto-correct; this one asks about substitution. They are different features: substitution was, as the question says, introduced in 10.6, whereas auto-correct was introduced in 10.7. – Peter Hosey Dec 10 '11 at 05:28
  • I didn't realize that there were two separate features (though when you said that your app wasn't doing it in 10.6, I think I can be forgiven for thinking you were being affected by a 10.7 feature). You have my apologies. – James Williams Dec 10 '11 at 19:31

1 Answers1

5

In Cocoa, the substitutions feature is called “automatic text replacement”. To disable it in an NSTextView, send the text view a setAutomaticTextReplacementEnabled: message.

You should consider whether it's really appropriate to disable that in your application, though. If your editor is intended to be used on code or data files, then yes, you probably should disable it. If it's for editing text files, however, it's probably better to leave it set to the default and let users discover the feature on their own (and turn it off themselves if they don't want it). If your application is a text editor that may be used on text or code, you can probably set it based on what format the file is in—for example, enable it for Markdown but disable it for Python.

The WebAutomaticDashSubstitutionEnabled preference is not relevant because, as its name says, it's a WebKit feature. NSTextView is part of AppKit and does not use WebKit. Also, automatic dash substitution, which is supported in NSTextView as well, is a different feature.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370