summaryrefslogtreecommitdiff
path: root/macui/ZeroTier One
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2017-03-27 10:55:47 -0700
committerGrant Limberg <grant.limberg@zerotier.com>2017-03-27 10:55:47 -0700
commit3d9a5a4f91bae48c700a01788e15b54a3d49c463 (patch)
treed667db43d2ff082384fe6389f60a8f931f2ceee4 /macui/ZeroTier One
parent683ba79ff0ed4b80c6240fa84d43838027449acd (diff)
downloadinfinitytier-3d9a5a4f91bae48c700a01788e15b54a3d49c463.tar.gz
infinitytier-3d9a5a4f91bae48c700a01788e15b54a3d49c463.zip
Popovers now appear to work

Diffstat (limited to 'macui/ZeroTier One')
-rw-r--r--macui/ZeroTier One/AppDelegate.m151
1 files changed, 95 insertions, 56 deletions
diff --git a/macui/ZeroTier One/AppDelegate.m b/macui/ZeroTier One/AppDelegate.m
index 5da6b354..ae3e042f 100644
--- a/macui/ZeroTier One/AppDelegate.m
+++ b/macui/ZeroTier One/AppDelegate.m
@@ -114,75 +114,114 @@
}
- (void)showNetworks {
- if(self.statusItem.button != nil) {
- NSStatusBarButton *button = self.statusItem.button;
- [self.networkListPopover showRelativeToRect:button.bounds
- ofView:button
- preferredEdge:NSMinYEdge];
-
- if(self.transientMonitor == nil) {
- self.transientMonitor =
- [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
- handler:^(NSEvent * _Nonnull e) {
- [NSEvent removeMonitor:self.transientMonitor];
- self.transientMonitor = nil;
- [self.networkListPopover close];
- }];
- }
+ NSButton *button = nil;
+ NSRect frame;
+ if ([self.statusItem respondsToSelector:@selector(button)]) {
+ button = self.statusItem.button;
+ frame = button.bounds;
+ } else if ([self.statusItem respondsToSelector:@selector(_button)]) {
+ button = [self.statusItem performSelector:@selector(_button)];
+ frame = button.bounds;
+ } else {
+ NSLog(@"Can't get view. Uh oh.");
+ return;
+ }
+
+ [self.networkListPopover showRelativeToRect:frame
+ ofView:button
+ preferredEdge:NSMinYEdge];
+
+ if(self.transientMonitor == nil) {
+ self.transientMonitor =
+ [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
+ handler:^(NSEvent * _Nonnull e) {
+ [NSEvent removeMonitor:self.transientMonitor];
+ self.transientMonitor = nil;
+ [self.networkListPopover close];
+ }];
}
}
- (void)joinNetwork {
- if(self.statusItem.button != nil) {
- NSStatusBarButton *button = self.statusItem.button;
- [self.joinNetworkPopover showRelativeToRect:button.bounds
- ofView:button
- preferredEdge:NSMinYEdge];
- if(self.transientMonitor == nil) {
- self.transientMonitor =
- [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
- handler:^(NSEvent * _Nonnull e) {
- [NSEvent removeMonitor:self.transientMonitor];
- self.transientMonitor = nil;
- [self.joinNetworkPopover close];
- }];
- }
+ NSButton *button = nil;
+ NSRect frame;
+ if ([self.statusItem respondsToSelector:@selector(button)]) {
+ button = self.statusItem.button;
+ frame = button.bounds;
+ } else if ([self.statusItem respondsToSelector:@selector(_button)]) {
+ button = [self.statusItem performSelector:@selector(_button)];
+ frame = button.bounds;
+ } else {
+ NSLog(@"Can't get view. Uh oh.");
+ return;
+ }
+
+ [self.joinNetworkPopover showRelativeToRect:button.bounds
+ ofView:button
+ preferredEdge:NSMinYEdge];
+ if(self.transientMonitor == nil) {
+ self.transientMonitor =
+ [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
+ handler:^(NSEvent * _Nonnull e) {
+ [NSEvent removeMonitor:self.transientMonitor];
+ self.transientMonitor = nil;
+ [self.joinNetworkPopover close];
+ }];
}
}
- (void)showPreferences {
- if(self.statusItem.button != nil) {
- NSStatusBarButton *button = self.statusItem.button;
- [self.preferencesPopover showRelativeToRect:button.bounds
- ofView:button
- preferredEdge:NSMinYEdge];
- if(self.transientMonitor == nil) {
- [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
- handler:^(NSEvent * _Nonnull e) {
- [NSEvent removeMonitor:self.transientMonitor];
- self.transientMonitor = nil;
- [self.preferencesPopover close];
- }];
- }
+ NSButton *button = nil;
+ NSRect frame;
+ if ([self.statusItem respondsToSelector:@selector(button)]) {
+ button = self.statusItem.button;
+ frame = button.bounds;
+ } else if ([self.statusItem respondsToSelector:@selector(_button)]) {
+ button = [self.statusItem performSelector:@selector(_button)];
+ frame = button.bounds;
+ } else {
+ NSLog(@"Can't get view. Uh oh.");
+ return;
+ }
+
+ [self.preferencesPopover showRelativeToRect:button.bounds
+ ofView:button
+ preferredEdge:NSMinYEdge];
+ if(self.transientMonitor == nil) {
+ [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
+ handler:^(NSEvent * _Nonnull e) {
+ [NSEvent removeMonitor:self.transientMonitor];
+ self.transientMonitor = nil;
+ [self.preferencesPopover close];
+ }];
}
}
- (void)showAbout {
- if(self.statusItem.button != nil) {
- NSStatusBarButton *button = self.statusItem.button;
- [self.aboutPopover showRelativeToRect:button.bounds
- ofView:button
- preferredEdge:NSMinYEdge];
- if(self.transientMonitor == nil) {
- [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
- handler:^(NSEvent * _Nonnull e) {
- [NSEvent removeMonitor:self.transientMonitor];
- self.transientMonitor = nil;
- [self.aboutPopover close];
- }];
- }
+ NSButton *button = nil;
+ NSRect frame;
+ if ([self.statusItem respondsToSelector:@selector(button)]) {
+ button = self.statusItem.button;
+ frame = button.bounds;
+ } else if ([self.statusItem respondsToSelector:@selector(_button)]) {
+ button = [self.statusItem performSelector:@selector(_button)];
+ frame = button.bounds;
+ } else {
+ NSLog(@"Can't get view. Uh oh.");
+ return;
+ }
+
+ [self.aboutPopover showRelativeToRect:button.bounds
+ ofView:button
+ preferredEdge:NSMinYEdge];
+ if(self.transientMonitor == nil) {
+ [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown)
+ handler:^(NSEvent * _Nonnull e) {
+ [NSEvent removeMonitor:self.transientMonitor];
+ self.transientMonitor = nil;
+ [self.aboutPopover close];
+ }];
}
-
}
- (void)quit {