NSEvent // Implement keyModifierFlags, etc.
This commit is contained in:
parent
308e068dfc
commit
f3673fa4a8
|
@ -59,7 +59,7 @@ public struct ShiftKeyUpChecker {
|
||||||
if isKeyDown {
|
if isKeyDown {
|
||||||
// modifier keydown event
|
// modifier keydown event
|
||||||
lastTime = Date()
|
lastTime = Date()
|
||||||
if event.modifierFlags == .shift { shiftIsBeingPressed = true }
|
if event.modifierFlags.intersection(.deviceIndependentFlagsMask) == .shift { shiftIsBeingPressed = true }
|
||||||
} else {
|
} else {
|
||||||
lastTime = Date(timeInterval: -3600 * 4, since: Date())
|
lastTime = Date(timeInterval: -3600 * 4, since: Date())
|
||||||
shiftIsBeingPressed = false
|
shiftIsBeingPressed = false
|
||||||
|
|
|
@ -94,6 +94,10 @@ public extension NSEvent {
|
||||||
return result <= UInt16.max ? UInt16(result) : UInt16.max
|
return result <= UInt16.max ? UInt16(result) : UInt16.max
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var keyModifierFlags: ModifierFlags { modifierFlags.intersection(.deviceIndependentFlagsMask) }
|
||||||
|
|
||||||
|
static var keyModifierFlags: ModifierFlags { Self.modifierFlags.intersection(.deviceIndependentFlagsMask) }
|
||||||
|
|
||||||
var isFlagChanged: Bool { type == .flagsChanged }
|
var isFlagChanged: Bool { type == .flagsChanged }
|
||||||
|
|
||||||
var isEmacsKey: Bool {
|
var isEmacsKey: Bool {
|
||||||
|
|
|
@ -187,7 +187,7 @@ public struct VwrPhraseEditorUI: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func callExternalAppToOpenPhraseFile() {
|
private func callExternalAppToOpenPhraseFile() {
|
||||||
let app: String = NSEvent.modifierFlags.contains(.option) ? "TextEdit" : "Finder"
|
let app: String = NSEvent.keyModifierFlags.contains(.option) ? "TextEdit" : "Finder"
|
||||||
delegate?.openPhraseFile(mode: selInputMode, type: selUserDataType, app: app)
|
delegate?.openPhraseFile(mode: selInputMode, type: selUserDataType, app: app)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ extension NSEvent: InputSignalProtocol {}
|
||||||
|
|
||||||
public protocol InputSignalProtocol {
|
public protocol InputSignalProtocol {
|
||||||
var modifierFlags: NSEvent.ModifierFlags { get }
|
var modifierFlags: NSEvent.ModifierFlags { get }
|
||||||
|
var keyModifierFlags: NSEvent.ModifierFlags { get }
|
||||||
var isTypingVertical: Bool { get }
|
var isTypingVertical: Bool { get }
|
||||||
var text: String { get }
|
var text: String { get }
|
||||||
var inputTextIgnoringModifiers: String? { get }
|
var inputTextIgnoringModifiers: String? { get }
|
||||||
|
|
|
@ -559,7 +559,7 @@ public class InputHandler: InputHandlerProtocol {
|
||||||
if prefs.halfWidthPunctuationEnabled { return "_half_punctuation_" }
|
if prefs.halfWidthPunctuationEnabled { return "_half_punctuation_" }
|
||||||
// 注意:這一行為 SHIFT+ALT+主鍵盤數字鍵專用,強制無視不同地區的鍵盤在這個按鍵組合下的符號輸入差異。
|
// 注意:這一行為 SHIFT+ALT+主鍵盤數字鍵專用,強制無視不同地區的鍵盤在這個按鍵組合下的符號輸入差異。
|
||||||
// 但如果去掉「input.isMainAreaNumKey」這個限定條件的話,可能會影響其他依賴 Shift 鍵輸入的符號。
|
// 但如果去掉「input.isMainAreaNumKey」這個限定條件的話,可能會影響其他依賴 Shift 鍵輸入的符號。
|
||||||
if input.isMainAreaNumKey, input.modifierFlags == [.option, .shift] { return "_shift_alt_punctuation_" }
|
if input.isMainAreaNumKey, input.keyModifierFlags == [.option, .shift] { return "_shift_alt_punctuation_" }
|
||||||
var result = ""
|
var result = ""
|
||||||
switch (input.isControlHold, input.isOptionHold) {
|
switch (input.isControlHold, input.isOptionHold) {
|
||||||
case (true, true): result.append("_alt_ctrl_punctuation_")
|
case (true, true): result.append("_alt_ctrl_punctuation_")
|
||||||
|
|
|
@ -41,7 +41,7 @@ extension InputHandler {
|
||||||
if candidates[highlightedIndex].keyArray.count < 2 || candidates[highlightedIndex].value.count < 2 {
|
if candidates[highlightedIndex].keyArray.count < 2 || candidates[highlightedIndex].value.count < 2 {
|
||||||
break manipulator
|
break manipulator
|
||||||
}
|
}
|
||||||
switch input.modifierFlags {
|
switch input.keyModifierFlags {
|
||||||
case [.option, .command] where input.keyCode == 27: // 減號鍵
|
case [.option, .command] where input.keyCode == 27: // 減號鍵
|
||||||
ctlCandidate.delegate?.candidatePairRightClicked(at: highlightedIndex, action: .toNerf)
|
ctlCandidate.delegate?.candidatePairRightClicked(at: highlightedIndex, action: .toNerf)
|
||||||
return true
|
return true
|
||||||
|
@ -274,8 +274,8 @@ extension InputHandler {
|
||||||
// MARK: - Flipping pages by using modified bracket keys (when they are not occupied).
|
// MARK: - Flipping pages by using modified bracket keys (when they are not occupied).
|
||||||
|
|
||||||
// Shift+Command+[] 被 Chrome 系瀏覽器佔用,所以改用 Ctrl。
|
// Shift+Command+[] 被 Chrome 系瀏覽器佔用,所以改用 Ctrl。
|
||||||
let ctrlCMD: Bool = input.modifierFlags == [.control, .command]
|
let ctrlCMD: Bool = input.keyModifierFlags == [.control, .command]
|
||||||
let ctrlShiftCMD: Bool = input.modifierFlags == [.control, .command, .shift]
|
let ctrlShiftCMD: Bool = input.keyModifierFlags == [.control, .command, .shift]
|
||||||
if ctrlShiftCMD || ctrlCMD {
|
if ctrlShiftCMD || ctrlCMD {
|
||||||
// 此處 JIS 鍵盤判定無法用於螢幕鍵盤。所以,螢幕鍵盤的場合,系統會依照 US 鍵盤的判定方案。
|
// 此處 JIS 鍵盤判定無法用於螢幕鍵盤。所以,螢幕鍵盤的場合,系統會依照 US 鍵盤的判定方案。
|
||||||
let isJIS: Bool = KBGetLayoutType(Int16(LMGetKbdType())) == kKeyboardJIS
|
let isJIS: Bool = KBGetLayoutType(Int16(LMGetKbdType())) == kKeyboardJIS
|
||||||
|
@ -293,7 +293,7 @@ extension InputHandler {
|
||||||
// MARK: - Flipping pages by using symbol menu keys (when they are not occupied).
|
// MARK: - Flipping pages by using symbol menu keys (when they are not occupied).
|
||||||
|
|
||||||
if input.isSymbolMenuPhysicalKey {
|
if input.isSymbolMenuPhysicalKey {
|
||||||
switch input.modifierFlags {
|
switch input.keyModifierFlags {
|
||||||
case .shift, [],
|
case .shift, [],
|
||||||
.option where state.type != .ofSymbolTable:
|
.option where state.type != .ofSymbolTable:
|
||||||
var updated = true
|
var updated = true
|
||||||
|
|
|
@ -339,7 +339,7 @@ extension InputHandler {
|
||||||
|
|
||||||
var displayedText = state.displayedText
|
var displayedText = state.displayedText
|
||||||
|
|
||||||
if input.modifierFlags == [.option, .shift] {
|
if input.keyModifierFlags == [.option, .shift] {
|
||||||
displayedText = displayedText.map(\.description).joined(separator: " ")
|
displayedText = displayedText.map(\.description).joined(separator: " ")
|
||||||
} else if readingOnly {
|
} else if readingOnly {
|
||||||
displayedText = commissionByCtrlCommandEnter()
|
displayedText = commissionByCtrlCommandEnter()
|
||||||
|
@ -446,7 +446,7 @@ extension InputHandler {
|
||||||
delegate.switchState(updatedState)
|
delegate.switchState(updatedState)
|
||||||
}
|
}
|
||||||
strCodePointBuffer = strCodePointBuffer.dropLast(1).description
|
strCodePointBuffer = strCodePointBuffer.dropLast(1).description
|
||||||
if input.modifierFlags == .option {
|
if input.keyModifierFlags == .option {
|
||||||
strCodePointBuffer.removeAll()
|
strCodePointBuffer.removeAll()
|
||||||
refreshState()
|
refreshState()
|
||||||
isCodePointInputMode = true
|
isCodePointInputMode = true
|
||||||
|
@ -488,7 +488,7 @@ extension InputHandler {
|
||||||
let steps = getStepsToNearbyNodeBorder(direction: .rear)
|
let steps = getStepsToNearbyNodeBorder(direction: .rear)
|
||||||
var actualSteps = 1
|
var actualSteps = 1
|
||||||
|
|
||||||
switch input.modifierFlags {
|
switch input.keyModifierFlags {
|
||||||
case .shift:
|
case .shift:
|
||||||
delegate.switchState(IMEState.ofAbortion())
|
delegate.switchState(IMEState.ofAbortion())
|
||||||
return true
|
return true
|
||||||
|
@ -507,7 +507,7 @@ extension InputHandler {
|
||||||
}
|
}
|
||||||
walk()
|
walk()
|
||||||
} else {
|
} else {
|
||||||
_ = input.modifierFlags == .option
|
_ = input.keyModifierFlags == .option
|
||||||
? clearComposerAndCalligrapher()
|
? clearComposerAndCalligrapher()
|
||||||
: letComposerAndCalligrapherDoBackSpace()
|
: letComposerAndCalligrapherDoBackSpace()
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,7 @@ extension InputHandler {
|
||||||
|
|
||||||
// macOS 認為 PC Delete 鍵訊號是必然有 .function 這個修飾鍵在起作用的。
|
// macOS 認為 PC Delete 鍵訊號是必然有 .function 這個修飾鍵在起作用的。
|
||||||
// 總之處理起來非常機車就是了。
|
// 總之處理起來非常機車就是了。
|
||||||
switch input.modifierFlags {
|
switch input.keyModifierFlags {
|
||||||
case _ where input.isShiftHold && !input.isOptionHold && !input.isControlHold:
|
case _ where input.isShiftHold && !input.isOptionHold && !input.isControlHold:
|
||||||
delegate.switchState(IMEState.ofAbortion())
|
delegate.switchState(IMEState.ofAbortion())
|
||||||
return true
|
return true
|
||||||
|
@ -1044,7 +1044,7 @@ extension InputHandler {
|
||||||
// 否則會導致對上下左右鍵與翻頁鍵的判斷失效。
|
// 否則會導致對上下左右鍵與翻頁鍵的判斷失效。
|
||||||
let notEmpty = state.hasComposition && !compositor.isEmpty && isComposerOrCalligrapherEmpty
|
let notEmpty = state.hasComposition && !compositor.isEmpty && isComposerOrCalligrapherEmpty
|
||||||
let bannedModifiers: NSEvent.ModifierFlags = [.option, .shift, .command, .control]
|
let bannedModifiers: NSEvent.ModifierFlags = [.option, .shift, .command, .control]
|
||||||
let noBannedModifiers = bannedModifiers.intersection(input.modifierFlags).isEmpty
|
let noBannedModifiers = bannedModifiers.intersection(input.keyModifierFlags).isEmpty
|
||||||
var triggered = input.isCursorClockLeft || input.isCursorClockRight
|
var triggered = input.isCursorClockLeft || input.isCursorClockRight
|
||||||
triggered = triggered || (input.isSpace && prefs.chooseCandidateUsingSpace)
|
triggered = triggered || (input.isSpace && prefs.chooseCandidateUsingSpace)
|
||||||
triggered = triggered || input.isPageDown || input.isPageUp
|
triggered = triggered || input.isPageDown || input.isPageUp
|
||||||
|
|
|
@ -47,7 +47,7 @@ public extension InputHandler {
|
||||||
case .kCarriageReturn, .kLineFeed: return handleEnter(input: input)
|
case .kCarriageReturn, .kLineFeed: return handleEnter(input: input)
|
||||||
case .kSymbolMenuPhysicalKeyJIS, .kSymbolMenuPhysicalKeyIntl:
|
case .kSymbolMenuPhysicalKeyJIS, .kSymbolMenuPhysicalKeyIntl:
|
||||||
let isJIS = keyCodeType == .kSymbolMenuPhysicalKeyJIS
|
let isJIS = keyCodeType == .kSymbolMenuPhysicalKeyJIS
|
||||||
switch input.modifierFlags {
|
switch input.keyModifierFlags {
|
||||||
case []:
|
case []:
|
||||||
return handlePunctuationList(alternative: false, isJIS: isJIS)
|
return handlePunctuationList(alternative: false, isJIS: isJIS)
|
||||||
case [.option, .shift]:
|
case [.option, .shift]:
|
||||||
|
@ -141,13 +141,13 @@ public extension InputHandler {
|
||||||
// 判斷是否響應傳統的漢音鍵盤符號模式熱鍵。
|
// 判斷是否響應傳統的漢音鍵盤符號模式熱鍵。
|
||||||
haninSymbolInput: if prefs.classicHaninKeyboardSymbolModeShortcutEnabled {
|
haninSymbolInput: if prefs.classicHaninKeyboardSymbolModeShortcutEnabled {
|
||||||
guard let x = input.inputTextIgnoringModifiers,
|
guard let x = input.inputTextIgnoringModifiers,
|
||||||
"¥\\".contains(x), input.modifierFlags.isEmpty
|
"¥\\".contains(x), input.keyModifierFlags.isEmpty
|
||||||
else { break haninSymbolInput }
|
else { break haninSymbolInput }
|
||||||
return handleHaninKeyboardSymbolModeToggle()
|
return handleHaninKeyboardSymbolModeToggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注音按鍵輸入與漢音鍵盤符號輸入處理。
|
// 注音按鍵輸入與漢音鍵盤符號輸入處理。
|
||||||
if isHaninKeyboardSymbolMode, [[], .shift].contains(input.modifierFlags) {
|
if isHaninKeyboardSymbolMode, [[], .shift].contains(input.keyModifierFlags) {
|
||||||
return handleHaninKeyboardSymbolModeInput(input: input)
|
return handleHaninKeyboardSymbolModeInput(input: input)
|
||||||
} else if let compositionHandled = handleComposition(input: input) {
|
} else if let compositionHandled = handleComposition(input: input) {
|
||||||
return compositionHandled
|
return compositionHandled
|
||||||
|
@ -158,8 +158,8 @@ public extension InputHandler {
|
||||||
|
|
||||||
// Ctrl+Command+[] 輪替候選字。
|
// Ctrl+Command+[] 輪替候選字。
|
||||||
// Shift+Command+[] 被 Chrome 系瀏覽器佔用,所以改用 Ctrl。
|
// Shift+Command+[] 被 Chrome 系瀏覽器佔用,所以改用 Ctrl。
|
||||||
let ctrlCMD: Bool = input.modifierFlags == [.control, .command]
|
let ctrlCMD: Bool = input.keyModifierFlags == [.control, .command]
|
||||||
let ctrlShiftCMD: Bool = input.modifierFlags == [.control, .command, .shift]
|
let ctrlShiftCMD: Bool = input.keyModifierFlags == [.control, .command, .shift]
|
||||||
revolveCandidateWithBrackets: if ctrlShiftCMD || ctrlCMD {
|
revolveCandidateWithBrackets: if ctrlShiftCMD || ctrlCMD {
|
||||||
if state.type != .ofInputting { break revolveCandidateWithBrackets }
|
if state.type != .ofInputting { break revolveCandidateWithBrackets }
|
||||||
// 此處 JIS 鍵盤判定無法用於螢幕鍵盤。所以,螢幕鍵盤的場合,系統會依照 US 鍵盤的判定方案。
|
// 此處 JIS 鍵盤判定無法用於螢幕鍵盤。所以,螢幕鍵盤的場合,系統會依照 US 鍵盤的判定方案。
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class SessionCtl: IMKInputController {
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
/// 當前 Caps Lock 按鍵是否被摁下。
|
/// 當前 Caps Lock 按鍵是否被摁下。
|
||||||
public var isCapsLocked: Bool { NSEvent.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock) }
|
public static var isCapsLocked: Bool { NSEvent.keyModifierFlags.contains(.capsLock) }
|
||||||
|
|
||||||
/// 當前這個 SessionCtl 副本是否處於英數輸入模式。
|
/// 當前這個 SessionCtl 副本是否處於英數輸入模式。
|
||||||
public var isASCIIMode: Bool {
|
public var isASCIIMode: Bool {
|
||||||
|
|
|
@ -80,7 +80,7 @@ public extension SessionCtl {
|
||||||
if #available(macOS 12, *) {
|
if #available(macOS 12, *) {
|
||||||
if event.type == .flagsChanged, event.keyCode == KeyCode.kCapsLock.rawValue {
|
if event.type == .flagsChanged, event.keyCode == KeyCode.kCapsLock.rawValue {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let isCapsLockTurnedOn = event.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock)
|
let isCapsLockTurnedOn = Self.isCapsLocked
|
||||||
let status = NSLocalizedString("NotificationSwitchRevolver", comment: "")
|
let status = NSLocalizedString("NotificationSwitchRevolver", comment: "")
|
||||||
guard PrefMgr.shared.showNotificationsWhenTogglingCapsLock else { return }
|
guard PrefMgr.shared.showNotificationsWhenTogglingCapsLock else { return }
|
||||||
Notifier.notify(
|
Notifier.notify(
|
||||||
|
@ -102,7 +102,7 @@ public extension SessionCtl {
|
||||||
// MARK: 針對客體的具體處理
|
// MARK: 針對客體的具體處理
|
||||||
|
|
||||||
// 不再讓威注音處理由 Shift 切換到的英文模式的按鍵輸入。
|
// 不再讓威注音處理由 Shift 切換到的英文模式的按鍵輸入。
|
||||||
if isASCIIMode, !isCapsLocked { return false }
|
if isASCIIMode, !Self.isCapsLocked { return false }
|
||||||
|
|
||||||
/// 這裡仍舊需要判斷 flags。之前使輸入法狀態卡住無法敲漢字的問題已在 InputHandler 內修復。
|
/// 這裡仍舊需要判斷 flags。之前使輸入法狀態卡住無法敲漢字的問題已在 InputHandler 內修復。
|
||||||
/// 這裡不判斷 flags 的話,用方向鍵前後定位光標之後,再次試圖觸發組字區時、反而會在首次按鍵時失敗。
|
/// 這裡不判斷 flags 的話,用方向鍵前後定位光標之後,再次試圖觸發組字區時、反而會在首次按鍵時失敗。
|
||||||
|
@ -166,7 +166,7 @@ public extension SessionCtl {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 準備修飾鍵,用來判定要新增的詞彙是否需要賦以非常低的權重。
|
// 準備修飾鍵,用來判定要新增的詞彙是否需要賦以非常低的權重。
|
||||||
Self.areWeNerfing = eventToDeal.modifierFlags == [.shift, .command]
|
Self.areWeNerfing = eventToDeal.keyModifierFlags == [.shift, .command]
|
||||||
|
|
||||||
/// 直接交給 commonEventHandler 來處理。
|
/// 直接交給 commonEventHandler 來處理。
|
||||||
let result = inputHandler.triageInput(event: eventToDeal)
|
let result = inputHandler.triageInput(event: eventToDeal)
|
||||||
|
|
|
@ -104,7 +104,7 @@ public extension SessionCtl {
|
||||||
let candidateString: String = candidateString?.string ?? ""
|
let candidateString: String = candidateString?.string ?? ""
|
||||||
if state.type == .ofAssociates {
|
if state.type == .ofAssociates {
|
||||||
// 聯想詞的 Shift+選字鍵的處理已經在其它位置實作完成。
|
// 聯想詞的 Shift+選字鍵的處理已經在其它位置實作完成。
|
||||||
let isShiftHold = NSEvent.modifierFlags.contains(.shift)
|
let isShiftHold = NSEvent.keyModifierFlags.contains(.shift)
|
||||||
if !(isShiftHold || PrefMgr.shared.alsoConfirmAssociatedCandidatesByEnter) {
|
if !(isShiftHold || PrefMgr.shared.alsoConfirmAssociatedCandidatesByEnter) {
|
||||||
switchState(IMEState.ofAbortion())
|
switchState(IMEState.ofAbortion())
|
||||||
return
|
return
|
||||||
|
|
|
@ -22,7 +22,7 @@ private extension Bool {
|
||||||
// 因為選單部分的內容又臭又長,所以就單獨拉到一個檔案內管理了。
|
// 因為選單部分的內容又臭又長,所以就單獨拉到一個檔案內管理了。
|
||||||
|
|
||||||
extension SessionCtl {
|
extension SessionCtl {
|
||||||
var optionKeyPressed: Bool { NSEvent.modifierFlags.contains(.option) }
|
var optionKeyPressed: Bool { NSEvent.keyModifierFlags.contains(.option) }
|
||||||
|
|
||||||
override public func menu() -> NSMenu! {
|
override public func menu() -> NSMenu! {
|
||||||
let menu = NSMenu(title: "Input Method Menu")
|
let menu = NSMenu(title: "Input Method Menu")
|
||||||
|
@ -217,7 +217,7 @@ extension SessionCtl {
|
||||||
public extension SessionCtl {
|
public extension SessionCtl {
|
||||||
@objc override func showPreferences(_: Any? = nil) {
|
@objc override func showPreferences(_: Any? = nil) {
|
||||||
osCheck: if #available(macOS 10.15, *) {
|
osCheck: if #available(macOS 10.15, *) {
|
||||||
switch NSEvent.modifierFlags {
|
switch NSEvent.keyModifierFlags {
|
||||||
case .option: break osCheck
|
case .option: break osCheck
|
||||||
// case .shift:
|
// case .shift:
|
||||||
// CtlPrefUIShared.shared.controller.show(preferencePane: PrefUITabs.tabGeneral.ssPaneIdentifier)
|
// CtlPrefUIShared.shared.controller.show(preferencePane: PrefUITabs.tabGeneral.ssPaneIdentifier)
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct VwrPrefPaneCassette: View {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
if NSEvent.modifierFlags == .option, !cassettePath.isEmpty {
|
if NSEvent.keyModifierFlags == .option, !cassettePath.isEmpty {
|
||||||
NSWorkspace.shared.activateFileViewerSelecting(
|
NSWorkspace.shared.activateFileViewerSelecting(
|
||||||
[URL(fileURLWithPath: cassettePath)]
|
[URL(fileURLWithPath: cassettePath)]
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
// requirements defined in MIT License.
|
// requirements defined in MIT License.
|
||||||
|
|
||||||
import BookmarkManager
|
import BookmarkManager
|
||||||
|
import CocoaExtension
|
||||||
import Shared
|
import Shared
|
||||||
import SSPreferences
|
import SSPreferences
|
||||||
import SwiftExtension
|
import SwiftExtension
|
||||||
|
@ -87,7 +88,7 @@ struct VwrPrefPaneDictionary: View {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
if NSEvent.modifierFlags == .option, !userDataFolderSpecified.isEmpty {
|
if NSEvent.keyModifierFlags == .option, !userDataFolderSpecified.isEmpty {
|
||||||
NSWorkspace.shared.activateFileViewerSelecting(
|
NSWorkspace.shared.activateFileViewerSelecting(
|
||||||
[URL(fileURLWithPath: userDataFolderSpecified)]
|
[URL(fileURLWithPath: userDataFolderSpecified)]
|
||||||
)
|
)
|
||||||
|
|
|
@ -337,7 +337,7 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func chooseUserDataFolderToSpecify(_: Any) {
|
@IBAction func chooseUserDataFolderToSpecify(_: Any) {
|
||||||
if NSEvent.modifierFlags == .option, let url = pctUserDictionaryFolder.url {
|
if NSEvent.keyModifierFlags == .option, let url = pctUserDictionaryFolder.url {
|
||||||
NSWorkspace.shared.activateFileViewerSelecting([url])
|
NSWorkspace.shared.activateFileViewerSelecting([url])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func chooseCassettePath(_: Any) {
|
@IBAction func chooseCassettePath(_: Any) {
|
||||||
if NSEvent.modifierFlags == .option, let url = pctCassetteFilePath.url {
|
if NSEvent.keyModifierFlags == .option, let url = pctCassetteFilePath.url {
|
||||||
NSWorkspace.shared.activateFileViewerSelecting([url])
|
NSWorkspace.shared.activateFileViewerSelecting([url])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
|
||||||
|
|
||||||
@IBAction func openExternallyPEButtonClicked(_: NSButton) {
|
@IBAction func openExternallyPEButtonClicked(_: NSButton) {
|
||||||
DispatchQueue.main.async { [self] in
|
DispatchQueue.main.async { [self] in
|
||||||
let app: String = NSEvent.modifierFlags.contains(.option) ? "TextEdit" : "Finder"
|
let app: String = NSEvent.keyModifierFlags.contains(.option) ? "TextEdit" : "Finder"
|
||||||
LMMgr.shared.openPhraseFile(mode: selInputMode, type: selUserDataType, app: app)
|
LMMgr.shared.openPhraseFile(mode: selInputMode, type: selUserDataType, app: app)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue