无法编辑NSTextView

时间:2013-09-02 15:27:18

标签: objective-c macos cocoa nstextview

我似乎无法在我创建的自定义NSPanel中编辑NSTextView

- (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];
}

0 个答案:

没有答案