diff --git a/Source/Base.lproj/preferences.xib b/Source/Base.lproj/preferences.xib index 26fb3441..4534c6b6 100644 --- a/Source/Base.lproj/preferences.xib +++ b/Source/Base.lproj/preferences.xib @@ -1,8 +1,8 @@ - + - + @@ -10,6 +10,7 @@ + @@ -18,14 +19,14 @@ - - + + - + - + @@ -46,7 +47,7 @@ - + @@ -55,7 +56,7 @@ - + @@ -67,7 +68,7 @@ - + @@ -76,7 +77,7 @@ - + @@ -85,7 +86,7 @@ - + @@ -94,7 +95,7 @@ - + @@ -103,7 +104,7 @@ - + @@ -129,7 +130,7 @@ - + @@ -155,7 +156,7 @@ - + @@ -178,7 +179,7 @@ + + + + + + + + + Item 1 + Item 2 + Item 3 + + + + + + + + + + + + + + + - + diff --git a/Source/PreferencesWindowController.h b/Source/PreferencesWindowController.h index 345ea254..538ddd5b 100644 --- a/Source/PreferencesWindowController.h +++ b/Source/PreferencesWindowController.h @@ -38,8 +38,13 @@ @private NSPopUpButton *__weak _fontSizePopUpButton; NSPopUpButton *__weak _basisKeyboardLayoutButton; + NSComboBox *__weak _selectionKeyComboBox; } + - (IBAction)updateBasisKeyboardLayoutAction:(id)sender; +- (IBAction)changeSelectionKeyAction:(id)sender; + @property (weak, nonatomic) IBOutlet NSPopUpButton *fontSizePopUpButton; @property (weak, nonatomic) IBOutlet NSPopUpButton *basisKeyboardLayoutButton; +@property (weak, nonatomic) IBOutlet NSComboBox *selectionKeyComboBox; @end diff --git a/Source/PreferencesWindowController.m b/Source/PreferencesWindowController.m index bbcb408d..df49850c 100644 --- a/Source/PreferencesWindowController.m +++ b/Source/PreferencesWindowController.m @@ -35,10 +35,12 @@ #import static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout"; // alphanumeric ("ASCII") input basis +static NSString *const kCandidateKeys = @"CandidateKeys"; @implementation PreferencesWindowController @synthesize fontSizePopUpButton = _fontSizePopUpButton; @synthesize basisKeyboardLayoutButton = _basisKeyboardLayoutButton; +@synthesize selectionKeyComboBox = _selectionKeyComboBox; - (void)awakeFromNib { @@ -89,6 +91,21 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout [self.basisKeyboardLayoutButton selectItem:(chosenItem ? chosenItem : usKeyboardLayoutItem)]; CFRelease(list); + + self.selectionKeyComboBox.usesDataSource = NO; + [self.selectionKeyComboBox removeAllItems]; + [self.selectionKeyComboBox addItemsWithObjectValues:@[ + @"123456789", + @"asdfghjkl", + @"asdfzxcvb" + ]]; + + NSString *ckeys = [[NSUserDefaults standardUserDefaults] stringForKey:kCandidateKeys]; + if (!ckeys || [ckeys stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length == 0) { + ckeys = @"123456789"; + } + + [self.selectionKeyComboBox setStringValue:ckeys]; } - (IBAction)updateBasisKeyboardLayoutAction:(id)sender @@ -98,4 +115,22 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout [[NSUserDefaults standardUserDefaults] setObject:sourceID forKey:kBasisKeyboardLayoutPreferenceKey]; } } + +- (IBAction)changeSelectionKeyAction:(id)sender +{ + NSString *keys = [[sender stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if (keys.length != 9 || + ![keys canBeConvertedToEncoding:NSASCIIStringEncoding] + ) { + NSString *defaultKeys = @"123456789"; + [self.selectionKeyComboBox setStringValue:defaultKeys]; + [[NSUserDefaults standardUserDefaults] setObject:defaultKeys forKey:kCandidateKeys]; + NSBeep(); + return; + } + + [self.selectionKeyComboBox setStringValue:keys]; + [[NSUserDefaults standardUserDefaults] setObject:keys forKey:kCandidateKeys]; +} + @end diff --git a/Source/zh-Hant.lproj/preferences.xib b/Source/zh-Hant.lproj/preferences.xib index 6e087795..e4d51139 100644 --- a/Source/zh-Hant.lproj/preferences.xib +++ b/Source/zh-Hant.lproj/preferences.xib @@ -1,8 +1,8 @@ - + - + @@ -10,6 +10,7 @@ + @@ -18,14 +19,14 @@ - - + + - + - + @@ -48,7 +49,7 @@ - + @@ -57,7 +58,7 @@ - + @@ -69,7 +70,7 @@ - + @@ -78,7 +79,7 @@ - + @@ -87,7 +88,7 @@ - + @@ -96,7 +97,7 @@ - + @@ -105,7 +106,7 @@ - + @@ -131,7 +132,7 @@ - + @@ -157,7 +158,7 @@ - + @@ -180,7 +181,7 @@ + + + + + + + + + Item 1 + Item 2 + Item 3 + + + + + + + + + + + + + + + - +