OSStatus TextViewEditCommandSupport( HIViewRef textView, Boolean on ) { OSStatus status = noErr; TXNCommandEventSupportOptions options = 0; TXNObject txnObj = HITextViewGetTXNObject(textView); // got TXNObject? require( txnObj != NULL, EXIT ); // get existing option settings... status = TXNGetCommandEventSupport( txnObj, &options ); require_noerr( status, EXIT ); // add or subtract edit command support as requested if( on ) { options |= kTXNSupportEditCommandProcessing; options |= kTXNSupportEditCommandUpdating; } else { if( options & kTXNSupportEditCommandProcessing ) options ^= kTXNSupportEditCommandProcessing; if( options & kTXNSupportEditCommandUpdating ) options ^= kTXNSupportEditCommandUpdating; } // reset modified options status = TXNSetCommandEventSupport(txnObj, options ); verify_noerr( status ); EXIT: ; return status; }
//--------------------------------------------------------------------- // Sets some default options in our main text view. // OSStatus MySetTextViewOptions(HIViewRef textView) { TXNCommandEventSupportOptions options; TXNObject txnObj; OSStatus status; // We are setting options that must be set in the // underlying MLTE object, so get a reference to it txnObj = HITextViewGetTXNObject(textView); require( (txnObj != NULL), CantGetTXNObject ); // Get the previous options status = TXNGetCommandEventSupport(txnObj, &options); require_noerr( status, CantGetCommandOptions ); // Add the font panel support options options |= kTXNSupportFontCommandProcessing; options |= kTXNSupportFontCommandUpdating; // Add the spelling panel support options options |= kTXNSupportSpellCheckCommandProcessing; options |= kTXNSupportSpellCheckCommandUpdating; // Apply above changes to the object status = TXNSetCommandEventSupport(txnObj, options); require_noerr( status, CantSetCommandOptions ); CantSetCommandOptions: CantGetCommandOptions: CantGetTXNObject: return status; }
OSStatus TextViewSpellingSupport( HIViewRef textView, Boolean on ) { OSStatus status = noErr; TXNCommandEventSupportOptions options = 0; TXNObject txnObj = HITextViewGetTXNObject(textView); // Got TXNObject? require( txnObj != NULL, EXIT ); // Get existing option settings... status = TXNGetCommandEventSupport( txnObj, &options ); require_noerr( status, EXIT ); // add or subtract spelling support as requested // (and enable/disable menu items appropriately) if( on ) { options |= kTXNSupportSpellCheckCommandProcessing; options |= kTXNSupportSpellCheckCommandUpdating; EnableMenuCommand(NULL, kHICommandShowSpellingPanel); EnableMenuCommand(NULL, kToggleAutoSpellcheckCommand); verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("SpellSupportEnable") )); } else { if( options & kTXNSupportSpellCheckCommandProcessing ) options ^= kTXNSupportSpellCheckCommandProcessing; if( options & kTXNSupportSpellCheckCommandUpdating ) options ^= kTXNSupportSpellCheckCommandUpdating; DisableMenuCommand(NULL, kHICommandShowSpellingPanel); DisableMenuCommand(NULL, kToggleAutoSpellcheckCommand); verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("SpellSupportDisable") )); } // Set auto spell check state accordingly status = TextViewSpellCheckAsYouType(textView, on); verify_noerr( status ); // reset modified options status = TXNSetCommandEventSupport(txnObj, options); verify_noerr( status ); HIViewSetNeedsDisplay( textView, true ); EXIT: ; return status; }
OSStatus TextViewFontPanelSupport( HIViewRef textView, Boolean on ) { OSStatus status = noErr; TXNCommandEventSupportOptions options = 0; TXNObject txnObj = HITextViewGetTXNObject(textView); // Got TXNObject? require( txnObj != NULL, EXIT ); // Get existing option settings... status = TXNGetCommandEventSupport( txnObj, &options ); require_noerr( status, EXIT ); // Add or subract font command support as requested, // (and enable/disable menu items appropriately) if( on ) { options |= kTXNSupportFontCommandProcessing; options |= kTXNSupportFontCommandUpdating; EnableMenuCommand(NULL, kHICommandShowHideFontPanel); if ( ! FPIsFontPanelVisible() ) verify_noerr( FPShowHideFontPanel() ); verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("FontPanelEnable") )); } else { if( options & kTXNSupportFontCommandProcessing ) options ^= kTXNSupportFontCommandProcessing; if( options & kTXNSupportFontCommandUpdating ) options ^= kTXNSupportFontCommandUpdating; DisableMenuCommand(NULL, kHICommandShowHideFontPanel); if ( FPIsFontPanelVisible() ) verify_noerr( FPShowHideFontPanel() ); verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("FontPanelDisable") )); } // reset modified options status = TXNSetCommandEventSupport(txnObj, options ); verify_noerr( status ); EXIT: ; return status; }