2

I can't seem to be able to edit a NSTextView in my custom NSPanel I am creating.

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

The view is not clickable nor editable. Instead you seem to be able to interact with the view behind my custom panel when clicking on the textview. Other buttons and views inside this custom panel works as expected however.

This is the header file:

@property (strong) IBOutlet NSPanel *annotationPanelWindow;
@property (strong) IBOutlet NSView *annotationPanelView;
@property (strong) IBOutlet NSTextView *textView;

- (id) initWithPoint:(CGPoint)point andAnnotation:(PDFAnnotationText*)annotation;

This is the code I use to create/open the panel:

-(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];
}
trojanfoe
  • 120,358
  • 21
  • 212
  • 242
Sunkas
  • 9,542
  • 6
  • 62
  • 102
  • Check that all of the parent views of the `NSTextView` have a frame that completely encloses your `NSTextView`'s frame. Generally when stuff like this happens it is because hit testing is failing due to incorrect frames. Also verify that the appropriate views have the `userInteractionEnabled` property set properly. – i_am_jorf Sep 02 '13 at 15:32
  • Why is this tagged iOS ? – Moxy Sep 02 '13 at 15:32
  • I don't like the look of that nib loading in the init method. – trojanfoe Sep 02 '13 at 16:10
  • Have checked the parents frames. NSView, NSTextView or NSScrollView does not have the property `userInteractionEnabled` – Sunkas Sep 03 '13 at 07:24
  • It seems so respond to touches as one can right-click on in and paste text. But I cannot left-click and start editing it. Any other ideas? – Sunkas Sep 03 '13 at 08:00
  • http://stackoverflow.com/questions/7561347/cant-edit-nstextfield-in-sheet-at-runtime Setting the title did make the textfield editable. But I do not want a title. Also, the window became detached from my main window which I do not want. – Sunkas Sep 03 '13 at 08:07
  • Used NSPopover instead! – Sunkas Sep 03 '13 at 13:32

0 Answers0