我似乎无法NSTextView
在我正在创建的自定义 NSPanel 中编辑 a 。
- (id) initWithPoint:(CGPoint)point andAnnotation:(PDFAnnotationText*)annotation {
if (!(self = [super init]))
return self;
if (self.annotationPanelWindow == NULL)
[NSBundle loadNibNamed: @"IBNoteAnnotationEditPanel" owner:self];
selectedAnnotation = annotation;
CGRect frame = self.annotationPanelWindow.frame;
frame.origin = point;
[self.annotationPanelWindow setFrame:frame display:YES animate:NO];
[self.annotationPanelView setHidden:NO];
[self.annotationPanelWindow orderFront:self];
//[self makeFirstResponder:self.textView];
[self.textView setString:annotation.contents];
return self;
}
该视图不可点击也不可编辑。相反,当单击 textview 时,您似乎能够与我的自定义面板后面的视图进行交互。但是,此自定义面板中的其他按钮和视图按预期工作。
这是头文件:
@property (strong) IBOutlet NSPanel *annotationPanelWindow;
@property (strong) IBOutlet NSView *annotationPanelView;
@property (strong) IBOutlet NSTextView *textView;
- (id) initWithPoint:(CGPoint)point andAnnotation:(PDFAnnotationText*)annotation;
这是我用来创建/打开面板的代码:
-(void)showNoteAnnotationEditPanel
{
CGPoint point = _activeAnnotation.bounds.origin;
point = [self convertPoint:point fromPage:_activeAnnotation.page];
point = [self convertPoint:point toView:nil];
self.noteAnnotationEditPanel = [[IBNoteAnnotationEditPanel alloc] initWithPoint:point andAnnotation:(PDFAnnotationText*)_activeAnnotation];
}