Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled delete and up/down arrow keys #54

Merged
merged 5 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Fastmate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
2E8C7D62275289C00015E582 /* FastmateApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E8C7D61275289C00015E582 /* FastmateApplication.m */; };
5D0F8E95240B910A00287BD1 /* PrintManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D0F8E94240B910A00287BD1 /* PrintManager.m */; };
5D14A8EB22C425B400A5ACE9 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 5D14A8EA22C425B400A5ACE9 /* Credits.rtf */; };
5D18D5022685E2EC002999F0 /* PDFKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D18D5012685E2EC002999F0 /* PDFKit.framework */; };
Expand All @@ -25,6 +26,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2E8C7D60275289C00015E582 /* FastmateApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FastmateApplication.h; sourceTree = "<group>"; };
2E8C7D61275289C00015E582 /* FastmateApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FastmateApplication.m; sourceTree = "<group>"; };
5D0F8E93240B910A00287BD1 /* PrintManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrintManager.h; sourceTree = "<group>"; };
5D0F8E94240B910A00287BD1 /* PrintManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PrintManager.m; sourceTree = "<group>"; };
5D14A8EA22C425B400A5ACE9 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
Expand Down Expand Up @@ -97,6 +100,8 @@
children = (
5D39BED92122383800693D7E /* AppDelegate.h */,
5D39BEDA2122383800693D7E /* AppDelegate.m */,
2E8C7D60275289C00015E582 /* FastmateApplication.h */,
2E8C7D61275289C00015E582 /* FastmateApplication.m */,
5D6EF779212E018700C84B4A /* MainWindowController.h */,
5D6EF77A212E018700C84B4A /* MainWindowController.m */,
5D6E3B352122FF9E00ED16C9 /* WebViewController.h */,
Expand Down Expand Up @@ -208,6 +213,7 @@
5DCFE8792258CEC5006B1A21 /* SettingsViewController.m in Sources */,
5D6E3B372122FF9E00ED16C9 /* WebViewController.m in Sources */,
5D0F8E95240B910A00287BD1 /* PrintManager.m in Sources */,
2E8C7D62275289C00015E582 /* FastmateApplication.m in Sources */,
5D39BEDB2122383800693D7E /* AppDelegate.m in Sources */,
5DC2AF2D225933BE004C94E5 /* VersionChecker.m in Sources */,
);
Expand Down
2 changes: 2 additions & 0 deletions Fastmate/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@

@property (nonatomic, strong) WebViewController *mainWebViewController;

/// returns YES if the delegate handled the key, NO if it needs to be forwarded on
- (BOOL)handleKey:(NSEvent *)event;
@end

36 changes: 32 additions & 4 deletions Fastmate/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@import Carbon.HIToolbox;
#import "AppDelegate.h"
#import "UnreadCountObserver.h"
#import "NotificationCenter.h"
#import "WebViewController.h"
#import "KVOBlockObserver.h"
#import "NotificationCenter.h"
#import "PrintManager.h"
#import "UnreadCountObserver.h"
#import "UserDefaultsKeys.h"
#import "UserDefaultsKeys.h"
#import "VersionChecker.h"
#import "PrintManager.h"
#import "WebViewController.h"

@interface AppDelegate () <VersionCheckerDelegate, NotificationCenterDelegate>

Expand Down Expand Up @@ -56,6 +58,7 @@ - (UnreadCountObserver *)unreadCountObserver {

- (void)applicationDidBecomeActive:(NSNotification *)notification {
[NSUserDefaults.standardUserDefaults registerDefaults:@{
ArrowNavigatesMessageListKey: @NO,
AutomaticUpdateChecksKey: @YES,
ShouldShowUnreadMailIndicatorKey: @YES,
ShouldShowUnreadMailInDockKey: @YES,
Expand Down Expand Up @@ -189,4 +192,29 @@ - (void)notificationCenter:(NotificationCenter *)center notificationClickedWithI
[self.mainWebViewController handleNotificationClickWithIdentifier:identifier];
}

#pragma mark - Raw key handler
- (BOOL)handleKey:(NSEvent *)event {
switch (event.keyCode) {
case kVK_UpArrow:
if ([NSUserDefaults.standardUserDefaults boolForKey:ArrowNavigatesMessageListKey]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here (and line 206) we look at the new setting, and either toss the event (letting the default behavior occur) or we attempt to have the mainWebViewController deal with it.

return [self.mainWebViewController nextMessage];
} else {
return NO;
}

case kVK_DownArrow:
if ([NSUserDefaults.standardUserDefaults boolForKey:ArrowNavigatesMessageListKey]) {
return [self.mainWebViewController previousMessage];
} else {
return NO;
}

case kVK_Delete:
return [self.mainWebViewController deleteMessage];

default:
return NO;
Copy link
Contributor Author

@kalkwarf kalkwarf Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next step is here in the delegate. If it's not one of the three raw keys, tell the application controller we didn't want the event.

}
}

@end
Loading