1

If a NSImageView is Editable and contains an image, it is possible to copy it's content via CMD+C

In my subclass i don't want the Editable property to be YES (cause of cut, drop, etc...) i just want to support the copy, but wasn't able to figure out, what makes the copy work

In my subclass i tried

- (void)copy:(id)sender {

}

- (BOOL)refusesFirstResponder {
    return NO;
}

- (BOOL)respondsToSelector:(SEL)aSelector {

    if (aSelector == @selector(copy:)) {
        return YES;
    }
    return [super respondsToSelector:aSelector];

}

but the copy command from the menu is grayed out and CMD+C doesn't work either (it triggers the menu copy:)

How to add support for copy an NSImageView subclass, which is Editable=NO

Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179

1 Answers1

0

The key was setting the NSImageView as the first responder

[self.view.window makeFirstResponder:self.imageView];

Not sure why it got autoselected when Editable was YES

Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179