One of my projects is an testing app where a student shouldn't be able to easily look up words while they're typing.
It's relatively easy to turn off automatic spelling checking in a NSTextView via setContinuousSpellCheckingEnabled:
and setAutomaticSpellingCorrectionEnabled:
.
I just discovered that it's very trivial for students to simply tap with three fingers upon any selected word in any app and up pops a helpful window containing a dictionary, thesaurus and even a Wikipedia entry if the word can be found there.
This is great functionality for 99% of MacOS apps but not appropriate for my testing app.
Now after a few months, Apple has provided me with a (undocumented and subtle) solution that works for 10.8 only and I may eventually provide it in the answers down below, but I need to have a solution that works for 10.7 as well (which is where this functionality came in).
There are three possible plans of attack on this problem but I'm not sure how to approach any of these three:
1)
I need to block this Lookup functionality from happening in this text view.
2)
I've already tried to delete the dictionary preferences (if they exist; if the user never opened Dictionary.app, there are no preferences) and the dictionary cache files (in "~/Library/Cache
", but this doesn't seem to improve the situation.
3)
Or is there a way to be able to detect the Trackpad setting that says "Use Lookup when doing a three fingered tap"? It's probably in some com.apple.*.plist somewhere or detectable via "defaults
" but I'm not certain where.
EDIT:
Only a bit of time left to hopefully solve this problem and award a bounty. Here is the approach that I was attempting with "defaults
":
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerTapGesture -bool false
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDoubleTapGesture -bool false
But I'm not 100% certain these are the correct gestures/keywords to type in. And even after typing them in (and verifying they were correctly saved via "defaults read com.apple.driver.AppleBluetoothMultitouch.trackpad
"), the dictionary LookUp window still appears.
Now here is the only thing that works, but it works only under MacOS 10.8 (which is where these methods were exposed/brought in). Simply override these two methods in your NSTextView subclass:
- (void)quickLookWithEvent:(NSEvent *)event;
- (void)quickLookPreviewItems:(id)sender;