Started converting MPPastBoardController API to use more flexible interface.

This commit is contained in:
Michael Starke
2021-02-15 22:03:22 +01:00
parent 1b04e5cfa2
commit 9e14e8301d
5 changed files with 57 additions and 8 deletions

View File

@@ -10,6 +10,7 @@
#import <KeePassKit/KeePassKit.h>
#import "MPEntryInspectorViewController.h"
#import "MPPasteBoardController.h"
@interface MPTOTPViewController ()
@@ -45,6 +46,25 @@
[self _didChangeAttribute:nil];
}
- (BOOL)textField:(NSTextField *)textField textView:(NSTextView *)textView performAction:(SEL)action {
if(action == @selector(copy:)) {
MPPasteboardOverlayInfoType info = MPPasteboardOverlayInfoCustom;
NSMutableString *selectedValue = [[NSMutableString alloc] init];
for(NSValue *rangeValue in textView.selectedRanges) {
[selectedValue appendString:[textView.string substringWithRange:rangeValue.rangeValue]];
}
NSString *name = NSLocalizedString(@"TOTP", "Field TOTP was copied to the pasteboard");
if(selectedValue.length == 0) {
return YES;
}
[MPPasteBoardController.defaultController copyObject:selectedValue overlayInfo:info name:name atView:self.view];
return NO;
}
return YES;
}
- (void)_didChangeAttribute:(NSNotification *)notification {
[self _updateDisplay];
}