Remove 'Start Dictation' and 'Special Characters' from menu
Quickest way to fix this is to set the title to "Edit " (with an extra space at the end).
In the interface builder select the Edit menu:
Then from the properties inspector, add an extra space to the title.
Here is the code I am using in my application to remove these automagically added entries to the Edit menu:
- (void) applicationDidFinishLaunching: (NSNotification*)aNotification
{
NSMenu* edit = [[[[NSApplication sharedApplication] mainMenu] itemWithTitle: @"Edit"] submenu];
if ([[edit itemAtIndex: [edit numberOfItems] - 1] action] == NSSelectorFromString(@"orderFrontCharacterPalette:"))
[edit removeItemAtIndex: [edit numberOfItems] - 1];
if ([[edit itemAtIndex: [edit numberOfItems] - 1] action] == NSSelectorFromString(@"startDictation:"))
[edit removeItemAtIndex: [edit numberOfItems] - 1];
if ([[edit itemAtIndex: [edit numberOfItems] - 1] isSeparatorItem])
[edit removeItemAtIndex: [edit numberOfItems] - 1];
}
NOTE: This code needs to go in applicationDidFinishLaunching:
or later, if you place it in applicationWillFinishLaunching:
the entries won't yet be added to the Edit
menu.
Also note, I am using NSSelectorFromString
as using @selector
causes "unknown selector" warnings. (Even with the warning the code does work, but I prefer to have no warnings in my code, so opted to use NSSelectorFromString
to avoid them.)
As mentioned in Mac OS X Internals: A Systems Approach and Qt Mac (Re)move "Special Characters..." action in Edit menu, you can do something like this in main() before you load the nib (but it is not supported API):
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledDictationMenuItem"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledCharacterPaletteMenuItem"];
Solution for Swift 4 using Storyboards
Add the following code to your AppDelegate
:
func applicationWillFinishLaunching(_ notification: Notification) {
UserDefaults.standard.set(true, forKey: "NSDisabledDictationMenuItem")
UserDefaults.standard.set(true, forKey: "NSDisabledCharacterPaletteMenuItem")
}
The applicationWillFinishLaunching
function is called early in the life-cycle of your application, before the menu is initialized. No need to manually hack the menu items.