From d24637ebbadfd31826609fd638c5851d3ce29f98 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 5 Sep 2018 20:51:28 +0200 Subject: Add label that displays the email address coming from `mailto` It starts with `mailto:`, so we remove that with a substring method call. --- CopyMailto/AppDelegate.h | 1 + CopyMailto/AppDelegate.m | 4 +++- CopyMailto/Base.lproj/MainMenu.xib | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CopyMailto/AppDelegate.h b/CopyMailto/AppDelegate.h index b46e3ff..321d100 100644 --- a/CopyMailto/AppDelegate.h +++ b/CopyMailto/AppDelegate.h @@ -10,6 +10,7 @@ @interface AppDelegate : NSObject { IBOutlet NSWindow *_window; + IBOutlet NSTextField *_email_address; } - (void)handleURLEvent:(NSAppleEventDescriptor *)event diff --git a/CopyMailto/AppDelegate.m b/CopyMailto/AppDelegate.m index 213f403..6f3477d 100644 --- a/CopyMailto/AppDelegate.m +++ b/CopyMailto/AppDelegate.m @@ -8,6 +8,8 @@ #import "AppDelegate.h" +const NSUInteger MAILTO_INDEX = 7; + @implementation AppDelegate - (void)applicationWillFinishLaunching:(NSNotification *)aNotification { @@ -28,7 +30,7 @@ { NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; - NSLog(@"%@", url); + [_email_address setStringValue:[url substringFromIndex:MAILTO_INDEX]]; } @end diff --git a/CopyMailto/Base.lproj/MainMenu.xib b/CopyMailto/Base.lproj/MainMenu.xib index 27b3521..c6b2415 100644 --- a/CopyMailto/Base.lproj/MainMenu.xib +++ b/CopyMailto/Base.lproj/MainMenu.xib @@ -15,6 +15,7 @@ + @@ -73,6 +74,17 @@ + + + + + + + + + + + -- cgit v1.2.3