From db87cb37fabb7ddddfc4a3472a351ca35be64e75 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 17 Nov 2016 08:23:43 -0500 Subject: Add MASShortcut widget to main window Also remove the `@property` for the window because we're old school. --- Low Battery Yup/AppDelegate.h | 8 +- Low Battery Yup/en.lproj/MainMenu.xib | 1556 ++------------------------------- 2 files changed, 77 insertions(+), 1487 deletions(-) diff --git a/Low Battery Yup/AppDelegate.h b/Low Battery Yup/AppDelegate.h index ad3458f..21e15f0 100644 --- a/Low Battery Yup/AppDelegate.h +++ b/Low Battery Yup/AppDelegate.h @@ -7,9 +7,11 @@ // #import +#import -@interface AppDelegate : NSObject - -@property (assign) IBOutlet NSWindow *window; +@interface AppDelegate : NSObject { + IBOutlet NSWindow *window; + IBOutlet MASShortcutView *shortcut_view; +} @end diff --git a/Low Battery Yup/en.lproj/MainMenu.xib b/Low Battery Yup/en.lproj/MainMenu.xib index be0c5a4..44ef13e 100644 --- a/Low Battery Yup/en.lproj/MainMenu.xib +++ b/Low Battery Yup/en.lproj/MainMenu.xib @@ -2,20 +2,21 @@ 1080 - 11D50 - 2457 - 1138.32 - 568.00 + 12F45 + 2844 + 1187.40 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin - 2457 + 2844 - NSWindowTemplate - NSView + NSCustomObject + NSCustomView NSMenu NSMenuItem - NSCustomObject + NSView + NSWindowTemplate com.apple.InterfaceBuilder.CocoaPlugin @@ -1292,19 +1293,37 @@ 15 2 - {{335, 390}, {480, 360}} + {{335, 390}, {480, 185}} 1954021376 Low Battery Yup NSWindow + {480, 185} + {480, 185} - + 256 - {480, 360} - - {{0, 0}, {2560, 1418}} - {10000000000000, 10000000000000} + + + + 268 + {{84, 83}, {313, 19}} + + + + _NS:9 + MASShortcutView + + + {480, 185} + + + + + {{0, 0}, {1440, 878}} + {480, 207} + {480, 207} YES @@ -1996,6 +2015,14 @@ 532 + + + shortcut_view + + + + 537 + @@ -2520,6 +2547,9 @@ 372 + + + @@ -2995,6 +3025,11 @@ + + 536 + + + @@ -3058,6 +3093,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin {{380, 496}, {480, 360}} @@ -3138,6 +3175,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3157,1498 +3195,48 @@ - 535 + 537 - ABCardController + AppDelegate NSObject - - id - id - id - id - id - id - id - - - - addCardViewField: - id - - - copy: - id - - - cut: - id - - - doDelete: - id - - - find: - id - - - paste: - id - - - saveChanges: - id - - - ABCardView - NSButton - NSManagedObjectContext - NSSearchField - NSTextField - NSWindow + MASShortcutView + NSTextField + MASShortcutView + NSWindow - - mCardView - ABCardView - - - mEditButton - NSButton - - - mManagedObjectContext - NSManagedObjectContext + + customShortcutView + MASShortcutView - - mSearchField - NSSearchField - - - mStatusTextField + + feedbackTextField NSTextField - - mWindow - NSWindow - - - - IBProjectSource - ./Classes/ABCardController.h - - - - ABCardView - NSView - - id - id - - - - commitAndSave: - id - - - statusImageClicked: - id - - - - NSObjectController - NSImageView - NSView - ABNameFrameView - NSView - NSImage - ABImageView - - - - mBindingsController - NSObjectController - - - mBuddyStatusImage - NSImageView - - - mHeaderView - NSView - - - mNameView - ABNameFrameView + + shortcut_view + MASShortcutView - - mNextKeyView - NSView - - - mUserImage - NSImage - - - mUserImageView - ABImageView - - - - IBProjectSource - ./Classes/ABCardView.h - - - - ABImageView - NSImageView - - id - id - id - id - - - - copy: - id - - - cut: - id - - - delete: - id - - - paste: - id + + window + NSWindow IBProjectSource - ./Classes/ABImageView.h - - - - DVTBorderedView - DVTLayoutView_ML - - contentView - NSView - - - contentView - - contentView - NSView - - - - IBProjectSource - ./Classes/DVTBorderedView.h - - - - DVTDelayedMenuButton - NSButton - - IBProjectSource - ./Classes/DVTDelayedMenuButton.h - - - - DVTGradientImageButton - NSButton - - IBProjectSource - ./Classes/DVTGradientImageButton.h - - - - DVTImageAndTextCell - NSTextFieldCell - - IBProjectSource - ./Classes/DVTImageAndTextCell.h - - - - DVTImageAndTextColumn - NSTableColumn - - IBProjectSource - ./Classes/DVTImageAndTextColumn.h - - - - DVTLayoutView_ML - NSView - - IBProjectSource - ./Classes/DVTLayoutView_ML.h - - - - DVTOutlineView - NSOutlineView - - IBProjectSource - ./Classes/DVTOutlineView.h - - - - DVTSplitView - NSSplitView - - IBProjectSource - ./Classes/DVTSplitView.h - - - - DVTStackView_ML - DVTLayoutView_ML - - IBProjectSource - ./Classes/DVTStackView_ML.h - - - - DVTTableView - NSTableView - - IBProjectSource - ./Classes/DVTTableView.h - - - - DVTViewController - NSViewController - - IBProjectSource - ./Classes/DVTViewController.h - - - - HFController - NSObject - - selectAll: - id - - - selectAll: - - selectAll: - id - - - - IBProjectSource - ./Classes/HFController.h + ./Classes/AppDelegate.h - HFRepresenterTextView + MASShortcutView NSView - - selectAll: - id - - - selectAll: - - selectAll: - id - - - - IBProjectSource - ./Classes/HFRepresenterTextView.h - - - - IBEditor - NSObject - - id - id - id - id - id - - - - changeFont: - id - - - performCopy: - id - - - performCut: - id - - - selectAll: - id - - - sizeSelectionToFit: - id - - - - IBProjectSource - ./Classes/IBEditor.h - - - - IDECapsuleListView - DVTStackView_ML - - dataSource - id - - - dataSource - - dataSource - id - - - - IBProjectSource - ./Classes/IDECapsuleListView.h - - - - IDEDMArrayController - NSArrayController - - IBProjectSource - ./Classes/IDEDMArrayController.h - - - - IDEDMEditor - IDEEditor - - DVTBorderedView - NSView - IDEDMEditorSourceListController - DVTSplitView - - - - bottomToolbarBorderView - DVTBorderedView - - - sourceListSplitViewPane - NSView - - - sourceListViewController - IDEDMEditorSourceListController - - - splitView - DVTSplitView - - - - IBProjectSource - ./Classes/IDEDMEditor.h - - - - IDEDMEditorController - IDEViewController - - IBProjectSource - ./Classes/IDEDMEditorController.h - - - - IDEDMEditorSourceListController - IDEDMEditorController - - DVTBorderedView - IDEDMEditor - DVTImageAndTextColumn - DVTOutlineView - NSTreeController - - - - borderedView - DVTBorderedView - - - parentEditor - IDEDMEditor - - - primaryColumn - DVTImageAndTextColumn - - - sourceListOutlineView - DVTOutlineView - - - sourceListTreeController - NSTreeController - - - - IBProjectSource - ./Classes/IDEDMEditorSourceListController.h - - - - IDEDMHighlightImageAndTextCell - DVTImageAndTextCell - - IBProjectSource - ./Classes/IDEDMHighlightImageAndTextCell.h - - - - IDEDataModelBrowserEditor - IDEDMEditorController - - IDEDataModelPropertiesTableController - IDECapsuleListView - NSArrayController - IDEDataModelPropertiesTableController - IDEDataModelEntityContentsEditor - IDEDataModelPropertiesTableController - - - - attributesTableViewController - IDEDataModelPropertiesTableController - - - capsuleView - IDECapsuleListView - - - entityArrayController - NSArrayController - - - fetchedPropertiesTableViewController - IDEDataModelPropertiesTableController - - - parentEditor - IDEDataModelEntityContentsEditor - - - relationshipsTableViewController - IDEDataModelPropertiesTableController - - - - IBProjectSource - ./Classes/IDEDataModelBrowserEditor.h - - - - IDEDataModelConfigurationEditor - IDEDMEditorController - - IDECapsuleListView - IDEDataModelEditor - IDEDataModelConfigurationTableController - - - - capsuleListView - IDECapsuleListView - - - parentEditor - IDEDataModelEditor - - - tableController - IDEDataModelConfigurationTableController - - - - IBProjectSource - ./Classes/IDEDataModelConfigurationEditor.h - - - - IDEDataModelConfigurationTableController - IDEDMEditorController - - NSArrayController - NSArrayController - IDEDataModelConfigurationEditor - XDTableView - - - - configurationsArrayController - NSArrayController - - - entitiesArrayController - NSArrayController - - - parentEditor - IDEDataModelConfigurationEditor - - - tableView - XDTableView - - - - IBProjectSource - ./Classes/IDEDataModelConfigurationTableController.h - - - - IDEDataModelDiagramEditor - IDEDMEditorController - - XDDiagramView - IDEDataModelEntityContentsEditor - - - - diagramView - XDDiagramView - - - parentEditor - IDEDataModelEntityContentsEditor - - IBProjectSource - ./Classes/IDEDataModelDiagramEditor.h - - - - IDEDataModelEditor - IDEDMEditor - - DVTDelayedMenuButton - DVTDelayedMenuButton - NSSegmentedControl - IDEDataModelConfigurationEditor - IDEDataModelEntityContentsEditor - IDEDataModelFetchRequestEditor - NSSegmentedControl - NSTabView - - - - addEntityButton - DVTDelayedMenuButton - - - addPropertyButton - DVTDelayedMenuButton - - - browserDiagramSegmentControl - NSSegmentedControl - - - configurationViewController - IDEDataModelConfigurationEditor - - - entityContentsViewController - IDEDataModelEntityContentsEditor - - - fetchRequestViewController - IDEDataModelFetchRequestEditor - - - hierarchySegmentControl - NSSegmentedControl - - - tabView - NSTabView - - - - IBProjectSource - ./Classes/IDEDataModelEditor.h - - - - IDEDataModelEntityContentsEditor - IDEDMEditorController - - IDEDataModelBrowserEditor - IDEDataModelDiagramEditor - IDEDataModelEditor - NSTabView - - - - browserViewController - IDEDataModelBrowserEditor - - - diagramViewController - IDEDataModelDiagramEditor - - - parentEditor - IDEDataModelEditor - - - tabView - NSTabView - - - - IBProjectSource - ./Classes/IDEDataModelEntityContentsEditor.h - - - - IDEDataModelFetchRequestEditor - IDEDMEditorController - - NSArrayController - IDEDataModelEditor - IDECapsuleListView - - - - entityController - NSArrayController - - - parentEditor - IDEDataModelEditor - - - tableView - IDECapsuleListView - - - - IBProjectSource - ./Classes/IDEDataModelFetchRequestEditor.h - - - - IDEDataModelPropertiesTableController - IDEDMEditorController - - IDEDMArrayController - NSTableColumn - NSArrayController - IDEDataModelBrowserEditor - IDEDMHighlightImageAndTextCell - XDTableView - - - - arrayController - IDEDMArrayController - - - entitiesColumn - NSTableColumn - - - entityArrayController - NSArrayController - - - parentEditor - IDEDataModelBrowserEditor - - - propertyNameAndImageCell - IDEDMHighlightImageAndTextCell - - - tableView - XDTableView - - - - IBProjectSource - ./Classes/IDEDataModelPropertiesTableController.h - - - - IDEDocDownloadsTableViewController - NSObject - - NSButtonCell - DVTTableView - IDEDocViewingPrefPaneController - - - - _downloadButtonCell - NSButtonCell - - - _tableView - DVTTableView - - - prefPaneController - IDEDocViewingPrefPaneController - - - - IBProjectSource - ./Classes/IDEDocDownloadsTableViewController.h - - - - IDEDocSetOutlineView - NSOutlineView - - IBProjectSource - ./Classes/IDEDocSetOutlineView.h - - - - IDEDocSetOutlineViewController - NSObject - - id - id - id - id - id - - - - getDocSetAction: - id - - - showProblemInfoForUpdate: - id - - - subscribeToPublisherAction: - id - - - unsubscribeFromPublisher: - id - - - updateDocSetAction: - id - - - - docSetOutlineView - IDEDocSetOutlineView - - - docSetOutlineView - - docSetOutlineView - IDEDocSetOutlineView - - - - IBProjectSource - ./Classes/IDEDocSetOutlineViewController.h - - - - IDEDocViewingPrefPaneController - IDEViewController - - id - id - id - id - id - id - id - id - id - id - id - - - - addSubscription: - id - - - checkForAndInstallUpdatesNow: - id - - - deleteDocSet: - id - - - downloadAction: - id - - - minimumFontSizeComboBoxAction: - id - - - minimumFontSizeEnabledAction: - id - - - showHelp: - id - - - showSubscriptionSheet: - id - - - subscriptionCancelAction: - id - - - toggleAutoCheckForAndInstallUpdates: - id - - - toggleDocSetInfo: - id - - - - DVTGradientImageButton - DVTGradientImageButton - DVTGradientImageButton - NSSplitView - NSView - NSView - DVTBorderedView - DVTBorderedView - NSButton - NSTextView - IDEDocSetOutlineViewController - IDEDocDownloadsTableViewController - NSComboBox - NSTextField - NSButton - NSTextField - NSWindow - NSButton - - - - _addButton - DVTGradientImageButton - - - _deleteButton - DVTGradientImageButton - - - _showInfoAreaButton - DVTGradientImageButton - - - _splitView - NSSplitView - - - _splitViewDocSetInfoSubview - NSView - - - _splitViewDocSetsListSubview - NSView - - - borderedViewAroundSplitView - DVTBorderedView - - - borderedViewBelowTable - DVTBorderedView - - - checkAndInstallNowButton - NSButton - - - docSetInfoTextView - NSTextView - - - docSetOutlineViewController - IDEDocSetOutlineViewController - - - downloadsTableViewController - IDEDocDownloadsTableViewController - - - minimumFontSizeControl - NSComboBox - - - noUpdatesAvailableMessage - NSTextField - - - showInfoButton - NSButton - - - subscriptionTextField - NSTextField - - - subscriptionWindow - NSWindow - - - validateAddSubscriptionButton - NSButton - - - - IBProjectSource - ./Classes/IDEDocViewingPrefPaneController.h - - - - IDEEditor - IDEViewController - - IBProjectSource - ./Classes/IDEEditor.h - - - - IDEViewController - DVTViewController - - IBProjectSource - ./Classes/IDEViewController.h - - - - IKImageView - - id - id - id - id - - - - copy: - id - - - crop: - id - - - cut: - id - - - paste: - id - - - - IBProjectSource - ./Classes/IKImageView.h - - - - NSDocument - - id - id - id - id - id - id - - - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - - - - IBProjectSource - ./Classes/NSDocument.h - - - - NSResponder - - _insertFindPattern: - id - - - _insertFindPattern: - - _insertFindPattern: - id - - - - IBProjectSource - ./Classes/NSResponder.h - - - - QLPreviewBubble - NSObject - - id - id - - - - hide: - id - - - show: - id - - - - parentWindow - NSWindow - - - parentWindow - - parentWindow - NSWindow - - - - IBProjectSource - ./Classes/QLPreviewBubble.h - - - - QTMovieView - - id - id - id - id - id - - - - showAll: - id - - - showCustomButton: - id - - - toggleLoops: - id - - - zoomIn: - id - - - zoomOut: - id - - - - IBProjectSource - ./Classes/QTMovieView.h - - - - WebView - - id - id - id - id - - - - reloadFromOrigin: - id - - - resetPageZoom: - id - - - zoomPageIn: - id - - - zoomPageOut: - id - - - - IBProjectSource - ./Classes/WebView.h - - - - XDDiagramView - NSView - - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - - - - _graphLayouterMenuItemAction: - id - - - _zoomPopUpButtonAction: - id - - - alignBottomEdges: - id - - - alignCentersHorizontallyInContainer: - id - - - alignCentersVerticallyInContainer: - id - - - alignHorizontalCenters: - id - - - alignLeftEdges: - id - - - alignRightEdges: - id - - - alignTopEdges: - id - - - alignVerticalCenters: - id - - - bringToFront: - id - - - collapseAllCompartments: - id - - - copy: - id - - - cut: - id - - - delete: - id - - - deleteBackward: - id - - - deleteForward: - id - - - deselectAll: - id - - - diagramZoomIn: - id - - - diagramZoomOut: - id - - - expandAllCompartments: - id - - - flipHorizontally: - id - - - flipVertically: - id - - - layoutGraphicsConcentrically: - id - - - layoutGraphicsHierarchically: - id - - - lock: - id - - - makeSameHeight: - id - - - makeSameWidth: - id - - - moveDown: - id - - - moveDownAndModifySelection: - id - - - moveLeft: - id - - - moveLeftAndModifySelection: - id - - - moveRight: - id - - - moveRightAndModifySelection: - id - - - moveUp: - id - - - moveUpAndModifySelection: - id - - - paste: - id - - - rollDownAllCompartments: - id - - - rollUpAllCompartments: - id - - - selectAll: - id - - - sendToBack: - id - - - sizeToFit: - id - - - toggleGridShown: - id - - - toggleHiddenGraphicsShown: - id - - - togglePageBreaksShown: - id - - - toggleRuler: - id - - - toggleSnapsToGrid: - id - - - unlock: - id - - - - _diagramController - IDEDataModelDiagramEditor - - - _diagramController - - _diagramController - IDEDataModelDiagramEditor - - - - IBProjectSource - ./Classes/XDDiagramView.h - - - - XDTableView - NSTableView - - showAllTableColumns: - id - - - showAllTableColumns: - - showAllTableColumns: - id - - - - IBProjectSource - ./Classes/XDTableView.h - - - - AppDelegate - NSObject - - id - id - - - - applicationShouldTerminate: - id - - - applicationWillFinishLaunching: - id - - - - IBProjectSource - ./Classes/AppDelegate.h + ./Classes/MASShortcutView.h -- cgit v1.2.3 From a984e2dd951bcbfe5e3e6374213eb9a5fd5423cf Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 06:58:56 -0500 Subject: Able to get a shortcut from the MASShortcutView Fuck damn it finally freaking works! Damn, just had to take a 1.5 hour nap after that. We're finally able to extract a shortcut out of the MASShortcutView. After trying a whole bunch of different things, I ultimately tried opening the debugger and figured out that for whatever reason the bindings weren't getting created and because of that my shortcut wasn't getting saved in the user defaults. Couldn't figure out how to get the binding to work even after includes and whatnot. Finally decided screw it I'm going to subclass the view and get the shortcut and store it in `NSUserDefaults` myself. So that's what we're going to do and this is the first step to getting that working. Hoo boy. Definitely need to vaccum the code after this. --- Low Battery Yup.d.xcodeproj/project.pbxproj | 6 ++ Low Battery Yup/AppDelegate.h | 6 +- Low Battery Yup/AppDelegate.m | 33 +++++++++- Low Battery Yup/ShortcutRecorder | 1 + Low Battery Yup/ShortcutView.h | 13 ++++ Low Battery Yup/ShortcutView.m | 19 ++++++ Low Battery Yup/en.lproj/MainMenu.xib | 98 +++++++++++++++++++++++++---- 7 files changed, 162 insertions(+), 14 deletions(-) create mode 160000 Low Battery Yup/ShortcutRecorder create mode 100644 Low Battery Yup/ShortcutView.h create mode 100644 Low Battery Yup/ShortcutView.m 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 = ""; }; + D15D90B61DF0465E001700CD /* ShortcutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShortcutView.m; sourceTree = ""; }; 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 #import +#import +#import @interface AppDelegate : NSObject { 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 index 0000000..3adf590 --- /dev/null +++ b/Low Battery Yup/ShortcutRecorder @@ -0,0 +1 @@ +Subproject commit 3adf5909a503b6ebf769a1e2a24fc389a3556ed3 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 + +@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 @@ 2844 + NSButton + NSButtonCell NSCustomObject NSCustomView NSMenu @@ -1305,21 +1307,50 @@ 256 - + 268 {{84, 83}, {313, 19}} + + _NS:9 + ShortcutView + + + + 268 + {{211, 18}, {192, 32}} + + _NS:9 - MASShortcutView + YES + + 67108864 + 134217728 + Defaults? + + LucidaGrande + 13 + 1044 + + _NS:9 + + -2038284288 + 129 + + + 200 + 25 + + NO {480, 185} - + {{0, 0}, {1440, 878}} {480, 207} @@ -2019,10 +2050,18 @@ shortcut_view - + 537 + + + logDefaults: + + + + 540 + @@ -2548,7 +2587,8 @@ 372 - + + @@ -3027,9 +3067,22 @@ 536 - + + + + + 538 + + + + + + 539 + + + @@ -3176,6 +3229,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3195,20 +3250,35 @@ - 537 + 540 AppDelegate NSObject + + logDefaults: + id + + + logDefaults: + + logDefaults: + id + + + MASShortcutView MASShortcutView NSTextField - MASShortcutView NSWindow + + _shortcut_view + MASShortcutView + customShortcutView MASShortcutView @@ -3217,10 +3287,6 @@ feedbackTextField NSTextField - - shortcut_view - MASShortcutView - window NSWindow @@ -3239,6 +3305,14 @@ ./Classes/MASShortcutView.h + + ShortcutView + MASShortcutView + + IBProjectSource + ./Classes/ShortcutView.h + + 0 -- cgit v1.2.3 From 91599928cb4412c85bb7f54e9146906070fd01cd Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 09:06:03 -0500 Subject: Clean up after a984e2dd951bcbfe5e3e6374213eb9a5fd5423cf Clean up the code after that commit. A whole bunch of stuff is no longer necessary so get rid of it all. --- Low Battery Yup/AppDelegate.h | 8 +--- Low Battery Yup/AppDelegate.m | 31 --------------- Low Battery Yup/en.lproj/MainMenu.xib | 74 ++--------------------------------- 3 files changed, 6 insertions(+), 107 deletions(-) diff --git a/Low Battery Yup/AppDelegate.h b/Low Battery Yup/AppDelegate.h index 9621fd4..a2c8ba9 100644 --- a/Low Battery Yup/AppDelegate.h +++ b/Low Battery Yup/AppDelegate.h @@ -7,15 +7,11 @@ // #import -#import -#import -#import +#import "ShortcutView.h" @interface AppDelegate : NSObject { IBOutlet NSWindow *window; - IBOutlet MASShortcutView *_shortcut_view; + IBOutlet ShortcutView *_shortcut_view; } -- (IBAction)logDefaults:(id)sender; - @end diff --git a/Low Battery Yup/AppDelegate.m b/Low Battery Yup/AppDelegate.m index 8a9005f..d90bc97 100644 --- a/Low Battery Yup/AppDelegate.m +++ b/Low Battery Yup/AppDelegate.m @@ -8,9 +8,6 @@ #import "AppDelegate.h" -static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; -static void *AppObservingContext = &AppObservingContext; - @implementation AppDelegate - (void)dealloc @@ -20,35 +17,7 @@ static void *AppObservingContext = &AppObservingContext; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - [_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/en.lproj/MainMenu.xib b/Low Battery Yup/en.lproj/MainMenu.xib index 989bd27..2961acf 100644 --- a/Low Battery Yup/en.lproj/MainMenu.xib +++ b/Low Battery Yup/en.lproj/MainMenu.xib @@ -11,8 +11,6 @@ 2844 - NSButton - NSButtonCell NSCustomObject NSCustomView NSMenu @@ -1313,38 +1311,9 @@ {{84, 83}, {313, 19}} - - _NS:9 - ShortcutView - - - - 268 - {{211, 18}, {192, 32}} - - _NS:9 - YES - - 67108864 - 134217728 - Defaults? - - LucidaGrande - 13 - 1044 - - _NS:9 - - -2038284288 - 129 - - - 200 - 25 - - NO + ShortcutView {480, 185} @@ -1352,7 +1321,7 @@ - {{0, 0}, {1440, 878}} + {{0, 0}, {2560, 1578}} {480, 207} {480, 207} YES @@ -2054,14 +2023,6 @@ 537 - - - logDefaults: - - - - 540 - @@ -2588,7 +2549,6 @@ - @@ -3070,19 +3030,6 @@ - - 538 - - - - - - - - 539 - - - @@ -3229,8 +3176,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3257,19 +3202,8 @@ AppDelegate NSObject - - logDefaults: - id - - - logDefaults: - - logDefaults: - id - - - MASShortcutView + ShortcutView MASShortcutView NSTextField NSWindow @@ -3277,7 +3211,7 @@ _shortcut_view - MASShortcutView + ShortcutView customShortcutView -- cgit v1.2.3 From f697d6f3e8445e781273c0e5862fde7c230bf579 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 09:36:16 -0500 Subject: ShortcutView: Store updated shortcut in NSUserDefaults This will enable us to access it later in the daemon. --- Low Battery Yup/ShortcutView.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Low Battery Yup/ShortcutView.m b/Low Battery Yup/ShortcutView.m index 5604834..216501f 100644 --- a/Low Battery Yup/ShortcutView.m +++ b/Low Battery Yup/ShortcutView.m @@ -8,12 +8,20 @@ #import "ShortcutView.h" +static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; + @implementation ShortcutView - (void)setShortcutValue:(MASShortcut *)shortcutValue { - [super setShortcutValue:shortcutValue]; - NSLog(@"%@", shortcutValue); + [super setShortcutValue:shortcutValue]; + + NSDictionary *shortcut = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInteger:[shortcutValue keyCode]], @"keyCode", + [NSNumber numberWithInteger:[shortcutValue modifierFlags]], @"modifierFlags", + nil]; + + [[NSUserDefaults standardUserDefaults] setObject:shortcut forKey:kPreferenceGlobalShortcut]; } @end -- cgit v1.2.3 From 42a8208805a5c648b4de0545fa504a30df6599cd Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 12:50:04 -0500 Subject: MainMenu.xib: Fix reference to `_shortcut_view` ivar Broke the reference to `_shortcut_view` in a984e2dd951bcbfe5e3e6374213eb9a5fd5423cf so when we called methods on it, they didn't work. This fixes it. Oh man that gave me a hard time. Glad I took a break and had an idea to call methods on the superclass and see if they worked. They did, but not methods on `ShorcutView`. So from that I figured out that I needed to update this reference. --- Low Battery Yup/en.lproj/MainMenu.xib | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Low Battery Yup/en.lproj/MainMenu.xib b/Low Battery Yup/en.lproj/MainMenu.xib index 2961acf..4b01316 100644 --- a/Low Battery Yup/en.lproj/MainMenu.xib +++ b/Low Battery Yup/en.lproj/MainMenu.xib @@ -1311,7 +1311,6 @@ {{84, 83}, {313, 19}} - _NS:9 ShortcutView @@ -2017,11 +2016,11 @@ - shortcut_view + _shortcut_view - 537 + 541 @@ -3195,7 +3194,7 @@ - 540 + 541 -- cgit v1.2.3 From 25e254a21668326a4241bdad6d3598d72c3bbfde Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 12:53:33 -0500 Subject: ShortcutView.h: Add reference to `(void)setShortcutValue:(MASShortcut*)` Because it's more explicit about the methods in our .m file and that makes it clearer. --- Low Battery Yup/ShortcutView.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Low Battery Yup/ShortcutView.h b/Low Battery Yup/ShortcutView.h index c30b08a..5eacb52 100644 --- a/Low Battery Yup/ShortcutView.h +++ b/Low Battery Yup/ShortcutView.h @@ -10,4 +10,6 @@ @interface ShortcutView : MASShortcutView +- (void)setShortcutValue:(MASShortcut *)shortcutValue; + @end -- cgit v1.2.3 From a2b75aae69c69148de6791c243429cc3e9f41d41 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 12:55:45 -0500 Subject: Show saved keyboard shortcut in the MASShortcutView If a global keyboard shortcut has been stored in the `NSUserDefaults`, display that in the shortcut selection widget. --- Low Battery Yup/AppDelegate.h | 1 + Low Battery Yup/AppDelegate.m | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Low Battery Yup/AppDelegate.h b/Low Battery Yup/AppDelegate.h index a2c8ba9..3998e46 100644 --- a/Low Battery Yup/AppDelegate.h +++ b/Low Battery Yup/AppDelegate.h @@ -7,6 +7,7 @@ // #import +#import #import "ShortcutView.h" @interface AppDelegate : NSObject { diff --git a/Low Battery Yup/AppDelegate.m b/Low Battery Yup/AppDelegate.m index d90bc97..9f3e367 100644 --- a/Low Battery Yup/AppDelegate.m +++ b/Low Battery Yup/AppDelegate.m @@ -8,6 +8,8 @@ #import "AppDelegate.h" +static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; + @implementation AppDelegate - (void)dealloc @@ -17,7 +19,14 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - + NSDictionary *saved_shortcut; + if ((saved_shortcut = [[NSUserDefaults standardUserDefaults] objectForKey:kPreferenceGlobalShortcut])) { + MASShortcut *shortcut = [MASShortcut + shortcutWithKeyCode:[[saved_shortcut objectForKey:@"keyCode"] unsignedIntegerValue] + modifierFlags:[[saved_shortcut objectForKey:@"modifierFlags"] unsignedIntegerValue]]; + + [_shortcut_view setShortcutValue:shortcut]; + } } @end -- cgit v1.2.3 From d9179f9a9b18ad73ca0fafb0e0e4f289f267b68d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 1 Dec 2016 13:03:50 -0500 Subject: Add Constants.h for `kPreferenceGlobalShortcut` Since `kPreferenceGlobalShortcut` was defined in two different files, extract it to a single file that gets imported where it's needed so we're not doubly defining the same string. --- Low Battery Yup.d.xcodeproj/project.pbxproj | 2 ++ Low Battery Yup/AppDelegate.m | 3 +-- Low Battery Yup/Constants.h | 1 + Low Battery Yup/ShortcutView.m | 3 +-- 4 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 Low Battery Yup/Constants.h diff --git a/Low Battery Yup.d.xcodeproj/project.pbxproj b/Low Battery Yup.d.xcodeproj/project.pbxproj index 157918d..7e8aa6c 100644 --- a/Low Battery Yup.d.xcodeproj/project.pbxproj +++ b/Low Battery Yup.d.xcodeproj/project.pbxproj @@ -66,6 +66,7 @@ D18C94C31DDC355400E03F87 /* Mouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mouse.h; sourceTree = ""; }; D18C94C41DDC355400E03F87 /* Mouse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Mouse.m; sourceTree = ""; }; D195AE4F1DDC774200A53A18 /* MASShortcut.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MASShortcut.xcodeproj; path = MASShortcut/MASShortcut.xcodeproj; sourceTree = ""; }; + D19DF1F41DF09CF30094C50F /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; D1F809DF1DDC6AA0001671E9 /* Low Battery Yup.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Low Battery Yup.app"; sourceTree = BUILT_PRODUCTS_DIR; }; D1F809E41DDC6AA0001671E9 /* Low Battery Yup-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Low Battery Yup-Info.plist"; sourceTree = ""; }; D1F809E61DDC6AA0001671E9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -175,6 +176,7 @@ D195AE4F1DDC774200A53A18 /* MASShortcut.xcodeproj */, D1F809EE1DDC6AA0001671E9 /* AppDelegate.h */, D1F809EF1DDC6AA0001671E9 /* AppDelegate.m */, + D19DF1F41DF09CF30094C50F /* Constants.h */, D15D90B51DF0465E001700CD /* ShortcutView.h */, D15D90B61DF0465E001700CD /* ShortcutView.m */, D1F809F11DDC6AA0001671E9 /* MainMenu.xib */, diff --git a/Low Battery Yup/AppDelegate.m b/Low Battery Yup/AppDelegate.m index 9f3e367..1ea2d64 100644 --- a/Low Battery Yup/AppDelegate.m +++ b/Low Battery Yup/AppDelegate.m @@ -7,8 +7,7 @@ // #import "AppDelegate.h" - -static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; +#import "Constants.h" @implementation AppDelegate diff --git a/Low Battery Yup/Constants.h b/Low Battery Yup/Constants.h new file mode 100644 index 0000000..8652225 --- /dev/null +++ b/Low Battery Yup/Constants.h @@ -0,0 +1 @@ +#define kPreferenceGlobalShortcut @"GlobalShortcut" diff --git a/Low Battery Yup/ShortcutView.m b/Low Battery Yup/ShortcutView.m index 216501f..3dc2ff3 100644 --- a/Low Battery Yup/ShortcutView.m +++ b/Low Battery Yup/ShortcutView.m @@ -7,8 +7,7 @@ // #import "ShortcutView.h" - -static NSString *const kPreferenceGlobalShortcut = @"GlobalShortcut"; +#import "Constants.h" @implementation ShortcutView -- cgit v1.2.3