Set touch bar default button directly instead of changing its keyEquivalent

This commit is contained in:
Bi11 committed 2017-01-11 00:44:15 +08:00
1 parent 7ae0e71b02
commit d95f420360
6 files changed
+14 -12

No files matched your search

+3 -3
View File
@@ -110,10 +110,10 @@
- (NSTouchBar *)makeTouchBar
{
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
[self.touchBarProvider addButtonWithButton:self.skipButton];
[self.touchBarProvider addButtonWithButton:self.skipButton isDefault:NO];
[self.touchBarProvider addSpace];
[self.touchBarProvider addButtonWithButton:self.laterButton];
[self.touchBarProvider addButtonWithButton:self.installButton].keyEquivalent = @"\r";
[self.touchBarProvider addButtonWithButton:self.laterButton isDefault:NO];
[self.touchBarProvider addButtonWithButton:self.installButton isDefault:YES];
[self.touchBarProvider addSpace];
[self.touchBarProvider addSpace];
return self.touchBarProvider.touchBar;
+1 -1
View File
@@ -135,7 +135,7 @@
- (NSTouchBar *)makeTouchBar
{
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
self.touchBarButton = [self.touchBarProvider addButtonWithButton:self.actionButton];
self.touchBarButton = [self.touchBarProvider addButtonWithButton:self.actionButton isDefault:[self.actionButton.keyEquivalent isEqualToString:@"\r"]];
return self.touchBarProvider.touchBar;
}
+1 -1
View File
@@ -15,7 +15,7 @@
@property (strong, readonly) NSTouchBar *touchBar;
-(instancetype)initWithIdentifier:(NSString *)identifier;
-(NSButton *)addButtonWithButton:(NSButton *)button;
-(NSButton *)addButtonWithButton:(NSButton *)button isDefault:(BOOL)isDefault;
-(void)addSpace;
@end
+4 -2
View File
@@ -46,14 +46,16 @@
return nil;
}
-(NSButton *)addButtonWithButton:(NSButton *)button
-(NSButton *)addButtonWithButton:(NSButton *)button isDefault:(BOOL)isDefault
{
NSString *itemId = [self.indentifier stringByAppendingFormat:@".button-%lu", self.touchBarItems.count];
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:itemId];
NSButton *buttonCopy = [NSButton buttonWithTitle:button.title target:button.target action:button.action];
buttonCopy.keyEquivalent = button.keyEquivalent;
buttonCopy.tag = button.tag;
if (isDefault) {
buttonCopy.keyEquivalent = @"\r";
}
[buttonCopy bind:@"title" toObject:button withKeyPath:@"title" options:nil];
[buttonCopy bind:@"enabled" toObject:button withKeyPath:@"enabled" options:nil];
+3 -3
View File
@@ -327,10 +327,10 @@
- (NSTouchBar *)makeTouchBar
{
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
[self.touchBarProvider addButtonWithButton:self.skipButton];
[self.touchBarProvider addButtonWithButton:self.skipButton isDefault:NO];
[self.touchBarProvider addSpace];
[self.touchBarProvider addButtonWithButton:self.laterButton];
[self.touchBarProvider addButtonWithButton:self.installButton].keyEquivalent = @"\r";
[self.touchBarProvider addButtonWithButton:self.laterButton isDefault:NO];
[self.touchBarProvider addButtonWithButton:self.installButton isDefault:YES];
[self.touchBarProvider addSpace];
[self.touchBarProvider addSpace];
return self.touchBarProvider.touchBar;
+2 -2
View File
@@ -170,8 +170,8 @@
- (NSTouchBar *)makeTouchBar
{
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
[self.touchBarProvider addButtonWithButton:self.cancelButton];
[self.touchBarProvider addButtonWithButton:self.checkButton].keyEquivalent = @"\r";
[self.touchBarProvider addButtonWithButton:self.cancelButton isDefault:NO];
[self.touchBarProvider addButtonWithButton:self.checkButton isDefault:YES];
return self.touchBarProvider.touchBar;
}