Detect if shift key is held down ASAP when launching test app

This commit is contained in:
Zorg committed 2016-08-14 13:44:10 -04:00
1 parent 57325c7507
commit bbfcd564d2
3 files changed
+18 -2

No files matched your search

+4 -1
View File
@@ -40,6 +40,9 @@ static NSString * const UPDATED_VERSION = @"2.0";
[[NSApplication sharedApplication] terminate:nil];
}
// Detect as early as possible if the shift key is held down
BOOL shiftKeyHeldDown = ([NSEvent modifierFlags] & NSShiftKeyMask) != 0;
// Apple's file manager may not work well over the network (on macOS 10.11.4 as of writing this), but at the same time
// I don't want to have to export SUFileManager in release mode. The test app is primarily
// aimed to be used in debug mode, so I think this is a good compromise
@@ -203,7 +206,7 @@ static NSString * const UPDATED_VERSION = @"2.0";
self.webServer = webServer;
// Show the Settings window
self.updateSettingsWindowController = [[SUUpdateSettingsWindowController alloc] init];
self.updateSettingsWindowController = [[SUUpdateSettingsWindowController alloc] initWithCustomUserDriver:shiftKeyHeldDown];
[self.updateSettingsWindowController showWindow:nil];
});
@@ -10,4 +10,6 @@
@interface SUUpdateSettingsWindowController : NSWindowController
- (instancetype)initWithCustomUserDriver:(BOOL)customUserDriver;
@end
@@ -13,6 +13,7 @@
@interface SUUpdateSettingsWindowController ()
@property (nonatomic) SPUUpdater *updater;
@property (nonatomic, readonly) BOOL customUserDriver;
@property (nonatomic) id<SPUStandardUserDriverProtocol> userDriver;
@end
@@ -20,8 +21,18 @@
@implementation SUUpdateSettingsWindowController
@synthesize updater = _updater;
@synthesize customUserDriver = _customUserDriver;
@synthesize userDriver = _userDriver;
- (instancetype)initWithCustomUserDriver:(BOOL)customUserDriver
{
self = [super init];
if (self != nil) {
_customUserDriver = customUserDriver;
}
return self;
}
- (NSString *)windowNibName
{
return NSStringFromClass([self class]);
@@ -34,7 +45,7 @@
// If the user is holding down command, we use the popup title user driver instead
id<SPUUserDriver, SPUStandardUserDriverProtocol> userDriver;
if (([NSEvent modifierFlags] & NSShiftKeyMask) != 0) {
if (self.customUserDriver) {
userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithApplicationBundle:applicationBundle window:self.window];
} else {
userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle applicationBundle:applicationBundle delegate:nil];