diff options
| -rw-r--r-- | Low Battery Yup.d.xcodeproj/project.pbxproj | 6 | ||||
| -rw-r--r-- | Low Battery Yup/AppDelegate.h | 6 | ||||
| -rw-r--r-- | Low Battery Yup/AppDelegate.m | 33 | ||||
| m--------- | Low Battery Yup/ShortcutRecorder | 0 | ||||
| -rw-r--r-- | Low Battery Yup/ShortcutView.h | 13 | ||||
| -rw-r--r-- | Low Battery Yup/ShortcutView.m | 19 | ||||
| -rw-r--r-- | Low Battery Yup/en.lproj/MainMenu.xib | 98 |
7 files changed, 161 insertions, 14 deletions
diff --git a/Low Battery Yup.d.xcodeproj/project.pbxproj b/Low Battery Yup.d.xcodeproj/project.pbxproj index 89d2710..157918d 100644 --- a/Low Battery Yup.d.xcodeproj/project.pbxproj +++ b/Low Battery Yup.d.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + D15D90B71DF0465E001700CD /* ShortcutView.m in Sources */ = {isa = PBXBuildFile; fileRef = D15D90B61DF0465E001700CD /* ShortcutView.m */; }; D18C94A31DDC33CF00E03F87 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D18C94A21DDC33CF00E03F87 /* Cocoa.framework */; }; D18C94AD1DDC33CF00E03F87 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D18C94AB1DDC33CF00E03F87 /* InfoPlist.strings */; }; D18C94AF1DDC33CF00E03F87 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D18C94AE1DDC33CF00E03F87 /* main.m */; }; @@ -48,6 +49,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + D15D90B51DF0465E001700CD /* ShortcutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShortcutView.h; sourceTree = "<group>"; }; + D15D90B61DF0465E001700CD /* ShortcutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShortcutView.m; sourceTree = "<group>"; }; D18C949E1DDC33CF00E03F87 /* Low Battery Yup.d.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Low Battery Yup.d.app"; sourceTree = BUILT_PRODUCTS_DIR; }; D18C94A21DDC33CF00E03F87 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; D18C94A51DDC33CF00E03F87 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; @@ -172,6 +175,8 @@ D195AE4F1DDC774200A53A18 /* MASShortcut.xcodeproj */, D1F809EE1DDC6AA0001671E9 /* AppDelegate.h */, D1F809EF1DDC6AA0001671E9 /* AppDelegate.m */, + D15D90B51DF0465E001700CD /* ShortcutView.h */, + D15D90B61DF0465E001700CD /* ShortcutView.m */, D1F809F11DDC6AA0001671E9 /* MainMenu.xib */, D1F809E31DDC6AA0001671E9 /* Supporting Files */, ); @@ -330,6 +335,7 @@ files = ( D1F809E91DDC6AA0001671E9 /* main.m in Sources */, D1F809F01DDC6AA0001671E9 /* AppDelegate.m in Sources */, + D15D90B71DF0465E001700CD /* ShortcutView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Low Battery Yup/AppDelegate.h b/Low Battery Yup/AppDelegate.h index 21e15f0..9621fd4 100644 --- a/Low Battery Yup/AppDelegate.h +++ b/Low Battery Yup/AppDelegate.h @@ -8,10 +8,14 @@ #import <Cocoa/Cocoa.h> #import <MASShortcut/MASShortcutView.h> +#import <MASShortcut/MASShortcutView+Bindings.h> +#import <MASShortcut/MASShortcutBinder.h> @interface AppDelegate : NSObject <NSApplicationDelegate> { IBOutlet NSWindow *window; - IBOutlet MASShortcutView *shortcut_view; + IBOutlet MASShortcutView *_shortcut_view; } +- (IBAction)logDefaults:(id)sender; + @end diff --git a/Low Battery Yup/AppDelegate.m b/Low Battery Yup/AppDelegate.m index 0c9bbdc..8a9005f 100644 --- a/Low Battery Yup/AppDelegate.m +++ b/Low Battery Yup/AppDelegate.m @@ -8,6 +8,9 @@ #import "AppDelegate.h" +static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; +static void *AppObservingContext = &AppObservingContext; + @implementation AppDelegate - (void)dealloc @@ -17,7 +20,35 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // Insert code here to initialize your application + [_shortcut_view setAssociatedUserDefaultsKey:kPreferenceGlobalShortcut]; + +// NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; +// [_shortcut_view bind:@"shortcutValue" toObject:defaults withKeyPath:@"thisisatest" options:nil]; + +// [defaults addObserver:self forKeyPath:@"thisisatest" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:AppObservingContext]; + +// [[MASShortcutBinder sharedBinder] +// bindShortcutWithDefaultsKey:kPreferenceGlobalShortcut +// toAction:^{NSLog(@"dudebro");}]; + +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + NSLog(@"OBSERVED"); + NSLog(@"%@", change); +} + +- (IBAction)logDefaults:(id)sender +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSLog(@"%@", [defaults objectForKey:[@"values." stringByAppendingString:kPreferenceGlobalShortcut]]); +// NSLog(@"%@", [defaults objectForKey:kPreferenceGlobalShortcut]); +// NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]); + +// NSLog(@"%@", [_shortcut_view shortcutValue]); +// NSLog(@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"thisisatest"]); +// [[NSUserDefaults standardUserDefaults] setObject:@"dude come on" forKey:@"thisisatest"]; } @end diff --git a/Low Battery Yup/ShortcutRecorder b/Low Battery Yup/ShortcutRecorder new file mode 160000 +Subproject 3adf5909a503b6ebf769a1e2a24fc389a3556ed diff --git a/Low Battery Yup/ShortcutView.h b/Low Battery Yup/ShortcutView.h new file mode 100644 index 0000000..c30b08a --- /dev/null +++ b/Low Battery Yup/ShortcutView.h @@ -0,0 +1,13 @@ +// +// ShortcutView.h +// Low Battery Yup.d +// +// Created by TW on 12/1/16. +// Copyright (c) 2016 TW. All rights reserved. +// + +#import <MASShortcut/MASShortcutView.h> + +@interface ShortcutView : MASShortcutView + +@end diff --git a/Low Battery Yup/ShortcutView.m b/Low Battery Yup/ShortcutView.m new file mode 100644 index 0000000..5604834 --- /dev/null +++ b/Low Battery Yup/ShortcutView.m @@ -0,0 +1,19 @@ +// +// ShortcutView.m +// Low Battery Yup.d +// +// Created by TW on 12/1/16. +// Copyright (c) 2016 TW. All rights reserved. +// + +#import "ShortcutView.h" + +@implementation ShortcutView + +- (void)setShortcutValue:(MASShortcut *)shortcutValue +{ + [super setShortcutValue:shortcutValue]; + NSLog(@"%@", shortcutValue); +} + +@end diff --git a/Low Battery Yup/en.lproj/MainMenu.xib b/Low Battery Yup/en.lproj/MainMenu.xib index 44ef13e..989bd27 100644 --- a/Low Battery Yup/en.lproj/MainMenu.xib +++ b/Low Battery Yup/en.lproj/MainMenu.xib @@ -11,6 +11,8 @@ <string key="NS.object.0">2844</string> </object> <array key="IBDocument.IntegratedClassDependencies"> + <string>NSButton</string> + <string>NSButtonCell</string> <string>NSCustomObject</string> <string>NSCustomView</string> <string>NSMenu</string> @@ -1305,21 +1307,50 @@ <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> <array class="NSMutableArray" key="NSSubviews"> - <object class="NSCustomView" id="1069525376"> + <object class="NSCustomView" id="489226571"> <reference key="NSNextResponder" ref="439893737"/> <int key="NSvFlags">268</int> <string key="NSFrame">{{84, 83}, {313, 19}}</string> <reference key="NSSuperview" ref="439893737"/> <reference key="NSWindow"/> + <reference key="NSNextKeyView" ref="840947810"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <string key="NSClassName">ShortcutView</string> + </object> + <object class="NSButton" id="840947810"> + <reference key="NSNextResponder" ref="439893737"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{211, 18}, {192, 32}}</string> + <reference key="NSSuperview" ref="439893737"/> + <reference key="NSWindow"/> <reference key="NSNextKeyView"/> <string key="NSReuseIdentifierKey">_NS:9</string> - <string key="NSClassName">MASShortcutView</string> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="316983695"> + <int key="NSCellFlags">67108864</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents">Defaults?</string> + <object class="NSFont" key="NSSupport"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">13</double> + <int key="NSfFlags">1044</int> + </object> + <string key="NSCellIdentifier">_NS:9</string> + <reference key="NSControlView" ref="840947810"/> + <int key="NSButtonFlags">-2038284288</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + <bool key="NSAllowsLogicalLayoutDirection">NO</bool> </object> </array> <string key="NSFrameSize">{480, 185}</string> <reference key="NSSuperview"/> <reference key="NSWindow"/> - <reference key="NSNextKeyView" ref="1069525376"/> + <reference key="NSNextKeyView" ref="489226571"/> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{480, 207}</string> @@ -2019,10 +2050,18 @@ <object class="IBOutletConnection" key="connection"> <string key="label">shortcut_view</string> <reference key="source" ref="976324537"/> - <reference key="destination" ref="1069525376"/> + <reference key="destination" ref="489226571"/> </object> <int key="connectionID">537</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">logDefaults:</string> + <reference key="source" ref="976324537"/> + <reference key="destination" ref="840947810"/> + </object> + <int key="connectionID">540</int> + </object> </array> <object class="IBMutableOrderedSet" key="objectRecords"> <array key="orderedObjects"> @@ -2548,7 +2587,8 @@ <int key="objectID">372</int> <reference key="object" ref="439893737"/> <array class="NSMutableArray" key="children"> - <reference ref="1069525376"/> + <reference ref="489226571"/> + <reference ref="840947810"/> </array> <reference key="parent" ref="972006081"/> </object> @@ -3027,9 +3067,22 @@ </object> <object class="IBObjectRecord"> <int key="objectID">536</int> - <reference key="object" ref="1069525376"/> + <reference key="object" ref="489226571"/> + <reference key="parent" ref="439893737"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">538</int> + <reference key="object" ref="840947810"/> + <array class="NSMutableArray" key="children"> + <reference ref="316983695"/> + </array> <reference key="parent" ref="439893737"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">539</int> + <reference key="object" ref="316983695"/> + <reference key="parent" ref="840947810"/> + </object> </array> </object> <dictionary class="NSMutableDictionary" key="flattenedProperties"> @@ -3176,6 +3229,8 @@ <string key="517.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="534.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="539.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -3195,20 +3250,35 @@ <nil key="activeLocalization"/> <dictionary class="NSMutableDictionary" key="localizations"/> <nil key="sourceID"/> - <int key="maxID">537</int> + <int key="maxID">540</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <array class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="IBPartialClassDescription"> <string key="className">AppDelegate</string> <string key="superclassName">NSObject</string> + <object class="NSMutableDictionary" key="actions"> + <string key="NS.key.0">logDefaults:</string> + <string key="NS.object.0">id</string> + </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <string key="NS.key.0">logDefaults:</string> + <object class="IBActionInfo" key="NS.object.0"> + <string key="name">logDefaults:</string> + <string key="candidateClassName">id</string> + </object> + </object> <dictionary class="NSMutableDictionary" key="outlets"> + <string key="_shortcut_view">MASShortcutView</string> <string key="customShortcutView">MASShortcutView</string> <string key="feedbackTextField">NSTextField</string> - <string key="shortcut_view">MASShortcutView</string> <string key="window">NSWindow</string> </dictionary> <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName"> + <object class="IBToOneOutletInfo" key="_shortcut_view"> + <string key="name">_shortcut_view</string> + <string key="candidateClassName">MASShortcutView</string> + </object> <object class="IBToOneOutletInfo" key="customShortcutView"> <string key="name">customShortcutView</string> <string key="candidateClassName">MASShortcutView</string> @@ -3217,10 +3287,6 @@ <string key="name">feedbackTextField</string> <string key="candidateClassName">NSTextField</string> </object> - <object class="IBToOneOutletInfo" key="shortcut_view"> - <string key="name">shortcut_view</string> - <string key="candidateClassName">MASShortcutView</string> - </object> <object class="IBToOneOutletInfo" key="window"> <string key="name">window</string> <string key="candidateClassName">NSWindow</string> @@ -3239,6 +3305,14 @@ <string key="minorKey">./Classes/MASShortcutView.h</string> </object> </object> + <object class="IBPartialClassDescription"> + <string key="className">ShortcutView</string> + <string key="superclassName">MASShortcutView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">./Classes/ShortcutView.h</string> + </object> + </object> </array> </object> <int key="IBDocument.localizationMode">0</int> |
