How can I make my NSTextField NOT highlight its text when the application starts?

前端 未结 3 1531
無奈伤痛
無奈伤痛 2021-02-07 16:10

When my application launches, the first NSTextField is being selected like this:

I can edit the NSTextField fine, but when I press enter to end the editing, th

3条回答
  •  后悔当初
    2021-02-07 16:57

    No need to subclass. Simply set refusesFirstResponder = YES;

    NSTextField *textField = [NSTextField new];
    textField.refusesFirstResponder = YES;
    

    That's it! Do that and it won't highlight the text in the field.

提交回复
热议问题