3

I have an NSTextField which is by default non editable and is first responder.
I would like to make the NSTextField editable/active as soon as I click on it.
I subclassed it and used the mousedown event:

- (void)mouseDown:(NSEvent *)theEvent
{
    NSLog(@"link mouse down");

    [self setEditable:TRUE];
}

However I need to click 2 times on the NSTextFIeld to become active and editable, but for each click I can properly see the NSLog "Mouse down".
Anything I forgot to do ? Thanks

Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89
  • 1
    That's totally normal behavior afaik. It works just the same way as in Finder when you click on a filename to edit it. – l'L'l Mar 12 '14 at 21:31
  • Thanks. And if I wanted to achieve what I want, what would be the way around ? – Laurent Crivello Mar 13 '14 at 06:11
  • Sure it's a double-click and not the common click-delay (again, as in Finder) that'll activate the text field..? – Jay Mar 15 '14 at 11:42

1 Answers1

1

In your NSTextField subclass, try overriding -acceptsFirstMouse: and returning YES. Get rid of your -mouseDown: override, though.

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135