LoginSignup
3
2

More than 3 years have passed since last update.

Swift:勝手にメニューに追加される「音声入力を開始」と「絵文字と記号」を除く方法

Posted at

macOSアプリ開発でNSTextViewNSTextFieldを使っていて、メニューに余計なものが勝手に追加されることに気づきました。「音声入力を開始」と「絵文字と記号」というやつです。
スクリーンショット 2020-02-19 0.59.29.png
これを取り除く方法を記しておきます。

AppDelegate.swift
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    func applicationWillFinishLaunching(_ notification: Notification) {
        UserDefaults.standard.set(true, forKey: "NSDisabledDictationMenuItem")
        UserDefaults.standard.set(true, forKey: "NSDisabledCharacterPaletteMenuItem")
        UserDefaults.standard.synchronize()
    }

    func applicationDidFinishLaunching(_ aNotification: Notification) {

    }

}

applicationWillFinishLaunchingの内部でUserDefaultsを介して設定をいじります。DidではなくWillなところがポイントです。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2