added reference builder menu item to textfields.

Reference builder is not working at the moment
This commit is contained in:
michael starke
2017-10-27 16:01:50 +02:00
parent a2bc25e671
commit d69ced43c9
3 changed files with 22 additions and 4 deletions

View File

@@ -21,6 +21,7 @@
//
#import "MPEntryInspectorViewController.h"
#import "MPInspectorViewController.h"
#import "MPAttachmentTableDataSource.h"
#import "MPAttachmentTableViewDelegate.h"
#import "MPCustomFieldTableViewDelegate.h"
@@ -515,6 +516,10 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
#pragma mark -
#pragma mark HNHUITextFieldDelegate
- (NSMenu *)textField:(NSTextField *)textField textView:(NSTextView *)view menu:(NSMenu *)menu {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SHOW_REFERENCE_BUILDER", @"Menu item to show the reference builder in a text view's context menu")action:@selector(showReferenceBuilder:) keyEquivalent:@""];
item.representedObject = textField;
[menu addItem:item];
return menu;
}

View File

@@ -39,6 +39,7 @@
- (IBAction)pickIcon:(id)sender;
- (IBAction)pickExpiryDate:(id)sender;
- (IBAction)showPluginData:(id)sender;
- (IBAction)showReferenceBuilder:(id)sender;
/* Separate call to ensure all registered objects are in place */
- (void)registerNotificationsForDocument:(NSDocument *)document;

View File

@@ -30,6 +30,7 @@
#import "MPIconImageView.h"
#import "MPNotifications.h"
#import "MPPluginDataViewController.h"
#import "MPReferenceBuilderViewController.h"
#import "KeePassKit/KeePassKit.h"
@@ -182,17 +183,28 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
#pragma mark Popup
- (IBAction)pickIcon:(id)sender {
NSAssert([sender isKindOfClass:NSView.class], @"");
[self _popupViewController:[[MPIconSelectViewController alloc] init] atView:(NSView *)sender];
[self _popupViewController:[[MPIconSelectViewController alloc] init] atView:sender];
}
- (IBAction)pickExpiryDate:(id)sender {
NSAssert([sender isKindOfClass:NSView.class], @"");
[self _popupViewController:[[MPDatePickingViewController alloc] init] atView:(NSView *)sender];
[self _popupViewController:[[MPDatePickingViewController alloc] init] atView:sender];
}
- (IBAction)showPluginData:(id)sender {
NSAssert([sender isKindOfClass:[NSView class]], @"");
[self _popupViewController:[[MPPluginDataViewController alloc] init] atView:(NSView *)sender];
NSAssert([sender isKindOfClass:NSView.class], @"");
[self _popupViewController:[[MPPluginDataViewController alloc] init] atView:sender];
}
- (IBAction)showReferenceBuilder:(id)sender {
NSView *location;
if([sender isKindOfClass:NSView.class]) {
location = sender;
}
else if([sender isKindOfClass:NSMenuItem.class]) {
location = [sender representedObject];
}
[self _popupViewController:[[MPReferenceBuilderViewController alloc] init] atView:location];
}
- (void)_popupViewController:(MPViewController *)vc atView:(NSView *)view {