-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ad409b
commit 6380d07
Showing
6 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// CopyableImageView.h | ||
// BetteReddit | ||
// | ||
// Created by Alex Taffe on 12/3/18. | ||
// Copyright © 2018 Alex Taffe. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "BRPost.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CopyableImageView : NSImageView | ||
|
||
@property (strong, nonatomic) BRPost *post; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// CopyableImageView.m | ||
// BetteReddit | ||
// | ||
// Created by Alex Taffe on 12/3/18. | ||
// Copyright © 2018 Alex Taffe. All rights reserved. | ||
// | ||
|
||
#import "CopyableImageView.h" | ||
|
||
@implementation CopyableImageView | ||
|
||
- (void)rightMouseUp:(NSEvent *)event{ | ||
NSMenu *theMenu = [[NSMenu alloc] initWithTitle:@"Contextual Menu"]; | ||
|
||
[theMenu insertItemWithTitle:@"Copy Link" action:@selector(copyLink) keyEquivalent:@"" atIndex:0]; | ||
[theMenu insertItemWithTitle:@"Copy Image" action:@selector(copyImage) keyEquivalent:@"" atIndex:1]; | ||
|
||
|
||
[NSMenu popUpContextMenu:theMenu withEvent:event forView:self]; | ||
} | ||
|
||
#pragma mark - Right click options | ||
-(void)copyLink{ | ||
[[NSPasteboard generalPasteboard] clearContents]; | ||
[[NSPasteboard generalPasteboard] setString:self.post.url forType:NSPasteboardTypeString]; | ||
} | ||
|
||
-(void)copyImage{ | ||
[[NSPasteboard generalPasteboard] clearContents]; | ||
[[NSPasteboard generalPasteboard] setData:[self.image TIFFRepresentation] forType:NSPasteboardTypeTIFF]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters