Repo // Add hotkey for calling reverse-lookup window.

This commit is contained in:
ShikiSuen 2022-12-19 14:41:45 +08:00
parent f27d08b221
commit 78635348d5
10 changed files with 48 additions and 17 deletions

View File

@ -80,4 +80,5 @@ public protocol PrefMgrProtocol {
var usingHotKeyHalfWidthASCII: Bool { get set } var usingHotKeyHalfWidthASCII: Bool { get set }
var usingHotKeyCurrencyNumerals: Bool { get set } var usingHotKeyCurrencyNumerals: Bool { get set }
var usingHotKeyCassette: Bool { get set } var usingHotKeyCassette: Bool { get set }
var usingHotKeyRevLookup: Bool { get set }
} }

View File

@ -87,6 +87,7 @@ public enum UserDef: String, CaseIterable {
case kUsingHotKeyHalfWidthASCII = "UsingHotKeyHalfWidthASCII" case kUsingHotKeyHalfWidthASCII = "UsingHotKeyHalfWidthASCII"
case kUsingHotKeyCurrencyNumerals = "UsingHotKeyCurrencyNumerals" case kUsingHotKeyCurrencyNumerals = "UsingHotKeyCurrencyNumerals"
case kUsingHotKeyCassette = "UsingHotKeyCassette" case kUsingHotKeyCassette = "UsingHotKeyCassette"
case kUsingHotKeyRevLookup = "UsingHotKeyRevLookup"
public static func resetAll() { public static func resetAll() {
UserDef.allCases.forEach { UserDef.allCases.forEach {

View File

@ -327,4 +327,7 @@ public class PrefMgr: PrefMgrProtocol {
@AppProperty(key: UserDef.kUsingHotKeyCassette.rawValue, defaultValue: true) @AppProperty(key: UserDef.kUsingHotKeyCassette.rawValue, defaultValue: true)
public var usingHotKeyCassette: Bool public var usingHotKeyCassette: Bool
@AppProperty(key: UserDef.kUsingHotKeyRevLookup.rawValue, defaultValue: true)
public var usingHotKeyRevLookup: Bool
} }

View File

@ -144,10 +144,12 @@ extension SessionCtl {
) )
} }
menu.addItem( let revLookupMenuItem = menu.addItem(
withTitle: "Reverse Lookup (Phonabets)".localized.withEllipsis, withTitle: "Reverse Lookup (Phonabets)".localized.withEllipsis,
action: #selector(callReverseLookupWindow(_:)) action: #selector(callReverseLookupWindow(_:)),
keyEquivalent: PrefMgr.shared.usingHotKeyRevLookup ? "/" : ""
) )
revLookupMenuItem.keyEquivalentModifierMask = [.command, .control]
menu.addItem(NSMenuItem.separator()) // --------------------- menu.addItem(NSMenuItem.separator()) // ---------------------

View File

@ -224,6 +224,8 @@ private struct VwrPrefPaneKeyboard_KeyboardShortcuts: View {
forKey: UserDef.kUsingHotKeyCurrencyNumerals.rawValue) forKey: UserDef.kUsingHotKeyCurrencyNumerals.rawValue)
@State private var selUsingHotKeyCassette = UserDefaults.standard.bool( @State private var selUsingHotKeyCassette = UserDefaults.standard.bool(
forKey: UserDef.kUsingHotKeyCassette.rawValue) forKey: UserDef.kUsingHotKeyCassette.rawValue)
@State private var selUsingHotKeyRevLookup = UserDefaults.standard.bool(
forKey: UserDef.kUsingHotKeyRevLookup.rawValue)
var body: some View { var body: some View {
HStack(alignment: .top, spacing: NSFont.systemFontSize) { HStack(alignment: .top, spacing: NSFont.systemFontSize) {
@ -252,6 +254,12 @@ private struct VwrPrefPaneKeyboard_KeyboardShortcuts: View {
PrefMgr.shared.usingHotKeyKangXi = selUsingHotKeyKangXi PrefMgr.shared.usingHotKeyKangXi = selUsingHotKeyKangXi
} }
) )
Toggle(
LocalizedStringKey("Reverse Lookup (Phonabets)"),
isOn: $selUsingHotKeyRevLookup.onChange {
PrefMgr.shared.usingHotKeyRevLookup = selUsingHotKeyRevLookup
}
)
} }
VStack(alignment: .leading) { VStack(alignment: .leading) {
Toggle( Toggle(

View File

@ -1295,14 +1295,14 @@
<point key="canvasLocation" x="101.5" y="-255"/> <point key="canvasLocation" x="101.5" y="-255"/>
</view> </view>
<view id="U4q-xw-mc0" userLabel="vwrKeyboard"> <view id="U4q-xw-mc0" userLabel="vwrKeyboard">
<rect key="frame" x="0.0" y="0.0" width="577" height="274"/> <rect key="frame" x="0.0" y="0.0" width="577" height="298"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" translatesAutoresizingMaskIntoConstraints="NO" id="0gn-BJ-qid"> <stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" translatesAutoresizingMaskIntoConstraints="NO" id="0gn-BJ-qid">
<rect key="frame" x="20" y="47" width="538" height="207"/> <rect key="frame" x="20" y="47" width="538" height="231"/>
<subviews> <subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" translatesAutoresizingMaskIntoConstraints="NO" id="v7J-Jh-97Y"> <stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" translatesAutoresizingMaskIntoConstraints="NO" id="v7J-Jh-97Y">
<rect key="frame" x="0.0" y="45" width="342" height="162"/> <rect key="frame" x="0.0" y="69" width="342" height="162"/>
<subviews> <subviews>
<textField autoresizesSubviews="NO" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IpX-f7-rTL"> <textField autoresizesSubviews="NO" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IpX-f7-rTL">
<rect key="frame" x="-2" y="147" width="317" height="15"/> <rect key="frame" x="-2" y="147" width="317" height="15"/>
@ -1496,11 +1496,11 @@
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
</customSpacing> </customSpacing>
</stackView> </stackView>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="9" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gwA-XL-zVB"> <stackView distribution="fill" orientation="vertical" alignment="leading" spacing="9" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" translatesAutoresizingMaskIntoConstraints="NO" id="gwA-XL-zVB">
<rect key="frame" x="350" y="0.0" width="188" height="207"/> <rect key="frame" x="350" y="0.0" width="188" height="231"/>
<subviews> <subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Md1-t7-hU4"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Md1-t7-hU4">
<rect key="frame" x="-2" y="192" width="125" height="15"/> <rect key="frame" x="-2" y="216" width="125" height="15"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Keyboard Shortcuts" id="xibKeyboardShortcuts"> <textFieldCell key="cell" lineBreakMode="clipping" title="Keyboard Shortcuts" id="xibKeyboardShortcuts">
<font key="font" metaFont="systemBold" size="12"/> <font key="font" metaFont="systemBold" size="12"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -1508,7 +1508,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<button verticalHuggingPriority="750" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="8fz-X4-HVS" userLabel="UsingHotKeySCPC"> <button verticalHuggingPriority="750" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="8fz-X4-HVS" userLabel="UsingHotKeySCPC">
<rect key="frame" x="-1" y="167.5" width="147" height="16"/> <rect key="frame" x="-1" y="191.5" width="147" height="16"/>
<buttonCell key="cell" type="check" title="Per-Char Select Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeySCPC"> <buttonCell key="cell" type="check" title="Per-Char Select Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeySCPC">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1518,7 +1518,7 @@
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ajS-Ja-Vxr" userLabel="UsingHotKeyKangXi"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ajS-Ja-Vxr" userLabel="UsingHotKeyKangXi">
<rect key="frame" x="-1" y="143.5" width="140" height="16"/> <rect key="frame" x="-1" y="167.5" width="140" height="16"/>
<buttonCell key="cell" type="check" title="Force KangXi Writing" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyKangXi"> <buttonCell key="cell" type="check" title="Force KangXi Writing" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyKangXi">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1528,7 +1528,7 @@
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZWc-3p-TII" userLabel="UsingHotKeyAssociates"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZWc-3p-TII" userLabel="UsingHotKeyAssociates">
<rect key="frame" x="-1" y="119.5" width="187" height="16"/> <rect key="frame" x="-1" y="143.5" width="187" height="16"/>
<buttonCell key="cell" type="check" title="Per-Char Associated Phrases" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyAssociates"> <buttonCell key="cell" type="check" title="Per-Char Associated Phrases" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyAssociates">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1538,7 +1538,7 @@
</connections> </connections>
</button> </button>
<button horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vbm-7v-Dtb" userLabel="UsingHotKeyJIS"> <button horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vbm-7v-Dtb" userLabel="UsingHotKeyJIS">
<rect key="frame" x="-1" y="95.5" width="189" height="16"/> <rect key="frame" x="-1" y="119.5" width="189" height="16"/>
<buttonCell key="cell" type="check" title="JIS Shinjitai Output" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyJIS"> <buttonCell key="cell" type="check" title="JIS Shinjitai Output" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyJIS">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1548,7 +1548,7 @@
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MVw-Gx-ueg" userLabel="UsingHotKeyCNS"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MVw-Gx-ueg" userLabel="UsingHotKeyCNS">
<rect key="frame" x="-1" y="71.5" width="116" height="16"/> <rect key="frame" x="-1" y="95.5" width="116" height="16"/>
<buttonCell key="cell" type="check" title="CNS11643 Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyCNS"> <buttonCell key="cell" type="check" title="CNS11643 Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyCNS">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1558,7 +1558,7 @@
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aBy-qb-ZL5" userLabel="UsingHotKeyHalfWidthASCII"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aBy-qb-ZL5" userLabel="UsingHotKeyHalfWidthASCII">
<rect key="frame" x="-1" y="47.5" width="189" height="16"/> <rect key="frame" x="-1" y="71.5" width="189" height="16"/>
<buttonCell key="cell" type="check" title="Half-Width Punctuation Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyHalfWidthASCII"> <buttonCell key="cell" type="check" title="Half-Width Punctuation Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingHotKeyHalfWidthASCII">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1568,7 +1568,7 @@
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JvA-GK-VEW" userLabel="CurrencyNumerals"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JvA-GK-VEW" userLabel="CurrencyNumerals">
<rect key="frame" x="-1" y="23.5" width="167" height="16"/> <rect key="frame" x="-1" y="47.5" width="167" height="16"/>
<buttonCell key="cell" type="check" title="Currency Numeral Output" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingCurrencyNumerals"> <buttonCell key="cell" type="check" title="Currency Numeral Output" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="xibUsingCurrencyNumerals">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1578,7 +1578,7 @@
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zZA-X1-GCy" userLabel="UsingHotKeyCassette"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zZA-X1-GCy" userLabel="UsingHotKeyCassette">
<rect key="frame" x="-1" y="-0.5" width="131" height="16"/> <rect key="frame" x="-1" y="23.5" width="131" height="16"/>
<buttonCell key="cell" type="check" title="CIN Cassette Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="1ll-Jn-OD5"> <buttonCell key="cell" type="check" title="CIN Cassette Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="1ll-Jn-OD5">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@ -1587,6 +1587,16 @@
<binding destination="32" name="value" keyPath="values.UsingHotKeyCassette" id="mDe-q0-XYa"/> <binding destination="32" name="value" keyPath="values.UsingHotKeyCassette" id="mDe-q0-XYa"/>
</connections> </connections>
</button> </button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="g3L-S4-NBx" userLabel="UsingHotKeyCassette">
<rect key="frame" x="-1" y="-0.5" width="184" height="16"/>
<buttonCell key="cell" type="check" title="Reverse Lookup (Phonabets)" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="1Pn-EV-mui">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
<connections>
<binding destination="32" name="value" keyPath="values.UsingHotKeyRevLookup" id="y9C-ob-Mw2"/>
</connections>
</button>
</subviews> </subviews>
<visibilityPriorities> <visibilityPriorities>
<integer value="1000"/> <integer value="1000"/>
@ -1598,6 +1608,7 @@
<integer value="1000"/> <integer value="1000"/>
<integer value="1000"/> <integer value="1000"/>
<integer value="1000"/> <integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities> </visibilityPriorities>
<customSpacing> <customSpacing>
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
@ -1609,6 +1620,7 @@
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing> </customSpacing>
</stackView> </stackView>
</subviews> </subviews>
@ -1626,7 +1638,7 @@
<constraint firstItem="0gn-BJ-qid" firstAttribute="leading" secondItem="U4q-xw-mc0" secondAttribute="leading" constant="20" symbolic="YES" id="MYd-6b-0XR"/> <constraint firstItem="0gn-BJ-qid" firstAttribute="leading" secondItem="U4q-xw-mc0" secondAttribute="leading" constant="20" symbolic="YES" id="MYd-6b-0XR"/>
<constraint firstItem="0gn-BJ-qid" firstAttribute="top" secondItem="U4q-xw-mc0" secondAttribute="top" constant="20" symbolic="YES" id="qgB-J1-68N"/> <constraint firstItem="0gn-BJ-qid" firstAttribute="top" secondItem="U4q-xw-mc0" secondAttribute="top" constant="20" symbolic="YES" id="qgB-J1-68N"/>
</constraints> </constraints>
<point key="canvasLocation" x="-466.5" y="-336"/> <point key="canvasLocation" x="-466.5" y="-324"/>
</view> </view>
<view wantsLayer="YES" id="nMV-YT-ex7" userLabel="vwrPhrases"> <view wantsLayer="YES" id="nMV-YT-ex7" userLabel="vwrPhrases">
<rect key="frame" x="0.0" y="0.0" width="577" height="508"/> <rect key="frame" x="0.0" y="0.0" width="577" height="508"/>

View File

@ -13,6 +13,7 @@
"18.title" = "Radio"; "18.title" = "Radio";
"1AW-xf-c2f.label" = "Keyboard"; "1AW-xf-c2f.label" = "Keyboard";
"1ll-Jn-OD5.title" = "CIN Cassette Mode"; "1ll-Jn-OD5.title" = "CIN Cassette Mode";
"1Pn-EV-mui.title" = "Reverse Lookup (Phonabets)";
"20.title" = "Radio"; "20.title" = "Radio";
"21.title" = "Horizontal"; "21.title" = "Horizontal";
"22.title" = "Vertical"; "22.title" = "Vertical";

View File

@ -13,6 +13,7 @@
"18.title" = "Radio"; "18.title" = "Radio";
"1AW-xf-c2f.label" = "キーボード"; "1AW-xf-c2f.label" = "キーボード";
"1ll-Jn-OD5.title" = "CIN カセットモード"; "1ll-Jn-OD5.title" = "CIN カセットモード";
"1Pn-EV-mui.title" = "注音音読逆引参照";
"20.title" = "Radio"; "20.title" = "Radio";
"21.title" = "横型陳列"; "21.title" = "横型陳列";
"22.title" = "縦型陳列"; "22.title" = "縦型陳列";

View File

@ -13,6 +13,7 @@
"18.title" = "Radio"; "18.title" = "Radio";
"1AW-xf-c2f.label" = "键盘"; "1AW-xf-c2f.label" = "键盘";
"1ll-Jn-OD5.title" = "CIN 磁带模式"; "1ll-Jn-OD5.title" = "CIN 磁带模式";
"1Pn-EV-mui.title" = "注音反查";
"20.title" = "Radio"; "20.title" = "Radio";
"21.title" = "横向布局"; "21.title" = "横向布局";
"22.title" = "纵向布局"; "22.title" = "纵向布局";

View File

@ -13,6 +13,7 @@
"18.title" = "Radio"; "18.title" = "Radio";
"1AW-xf-c2f.label" = "鍵盤"; "1AW-xf-c2f.label" = "鍵盤";
"1ll-Jn-OD5.title" = "CIN 磁帶模式"; "1ll-Jn-OD5.title" = "CIN 磁帶模式";
"1Pn-EV-mui.title" = "注音反查";
"20.title" = "Radio"; "20.title" = "Radio";
"21.title" = "橫向佈局"; "21.title" = "橫向佈局";
"22.title" = "縱向佈局"; "22.title" = "縱向佈局";