This isn't really straight forward, since a NSSearchField
is a subclass of NSTextField
and not NSTextView
. However, each NSTextField
uses a proxy NSTextView
to do the drawing, and this proxy NSTextView
(called the field editor), is maintained by the current window. So, what you want to do is to create your custom NSTextView
subclass, instantiate it somewhere in your window controller (or whatever you use as your windows delegate) and then create the following method: windowWillReturnFieldEditor:toObject:
.
In the method you check if the toObject is your search field (or just any search field, in case you want to override it for every search field in the window), and then return your custom NSTextView
, otherwise return nil
for the default field editor with the default behaviour.