Changeset 448 for trunk/ICeCoffEE


Ignore:
Timestamp:
03/10/08 10:59:02 (17 years ago)
Author:
Nicholas Riley
Message:

Disable spelling and grammar correction marks during selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEWebKit.m

    r446 r448  
    3737@end
    3838
     39// from WebViewPrivate.h (will become public, part of WebViewEditing)
     40@interface WebView (webViewGrammarChecking)
     41- (BOOL)isGrammarCheckingEnabled;
     42- (void)setGrammarCheckingEnabled:(BOOL)flag;
     43@end
     44
    3945@implementation ICeCoffEEWebKit
    4046
     
    8086    WebView *webView = [(WebHTMLView *)self _webView];
    8187    BOOL isEditable = [webView isEditable];
     88    BOOL isContinuousSpellCheckingEnabled = NO, isGrammarCheckingEnabled = NO;
    8289
    8390    if (isEditable) {
     
    9299
    93100    @try {
    94         if (!isEditable)
     101        if (!isEditable) {
    95102            [webView setEditable: YES];
     103       
     104            // don't want spelling/grammar marks to persist when view is made uneditable again
     105            if ([webView respondsToSelector: @selector(isContinuousSpellCheckingEnabled)] &&
     106                (isContinuousSpellCheckingEnabled = [webView isContinuousSpellCheckingEnabled])) {
     107                if ([webView respondsToSelector: @selector(setContinuousSpellCheckingEnabled:)])
     108                    [webView setContinuousSpellCheckingEnabled: NO];
     109                else
     110                    isContinuousSpellCheckingEnabled = NO; // don't restore
     111            }
     112
     113            if ([webView respondsToSelector: @selector(isGrammarCheckingEnabled)] &&
     114                (isGrammarCheckingEnabled = [webView isGrammarCheckingEnabled])) {
     115                if ([webView respondsToSelector: @selector(setGrammarCheckingEnabled:)])
     116                    [webView setGrammarCheckingEnabled: NO];
     117                else
     118                    isGrammarCheckingEnabled = NO; // don't restore
     119            }
     120        }
     121
    96122
    97123        NSPoint viewClickPt = [webView convertPoint: downPt fromView: nil];
     
    162188        [selectedRange release]; selectedRange = nil;
    163189        [downEvent release]; downEvent = nil;
    164         if (!isEditable)
     190        if (!isEditable) {
    165191            [webView setEditable: NO];
     192            if (isContinuousSpellCheckingEnabled)
     193                [webView setContinuousSpellCheckingEnabled: YES];
     194            if (isGrammarCheckingEnabled)
     195                [webView setGrammarCheckingEnabled: YES];
     196        }
    166197    }
    167198
Note: See TracChangeset for help on using the changeset viewer.