From d58195843680bf4acb5981a654ad7e83e80bef5a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 15 Feb 2022 21:59:18 +0800 Subject: [PATCH] PrefWindow // Use switch-case to handle dynamic keyboard layouts. --- Source/WindowControllers/ctlPrefWindow.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift index 12e02c80..d49f4d25 100644 --- a/Source/WindowControllers/ctlPrefWindow.swift +++ b/Source/WindowControllers/ctlPrefWindow.swift @@ -144,10 +144,13 @@ extension RangeReplaceableCollection where Element: Hashable { basisKeyboardLayoutButton.menu?.addItem(menuItem) } - if (basisKeyboardLayoutID == "com.apple.keylayout.ZhuyinBopomofo") { + switch basisKeyboardLayoutID { + case "com.apple.keylayout.ZhuyinBopomofo": chosenBaseKeyboardLayoutItem = menuItem_AppleZhuyinBopomofo - } else if basisKeyboardLayoutID == "com.apple.keylayout.ZhuyinEten" { + case "com.apple.keylayout.ZhuyinEten": chosenBaseKeyboardLayoutItem = menuItem_AppleZhuyinEten + default: + break // nothing to do } basisKeyboardLayoutButton.select(chosenBaseKeyboardLayoutItem ?? usKeyboardLayoutItem)