0
votes

I have an NSTextView object within a complex custom view. I need that custom view to be the first responder (for multiple reasons, e.g. to have its focus ring drawn properly). But the NSTextView cursor must still blink as if the text view was the first responder.

Here's essentially what I want to see in my application (a screenshot of the search field in Apple Mail):

enter image description here

Note that the text view is the empty area with the cursor located at the beginning of it. The other elements belong to the parent custom view, which has the focus ring around it. The cursor is blinking!

1
Which view should get the keydown events? It looks like the text view in the search field is the field editor in a (custom subclass of) NSTokenField, NSSearchField or NSTextField. - Willeke
I don't really care which view will get the keydown events, I can route them to the correct destination (the text view) in any case. Does it matter which type of the view is the search field in the screenshot? I tried subclassing NSTextField, but then I had to switch to NSTextView as providing more API flexibility. - evgeny
The screenshot is of a control containing the field editor text view. The control has focus and the text view is the first responder. - Willeke
Sorry, that doesn't answer the question. I couldn't implement that behavior using the standard Cocoa controls. The text view always has its own smaller focus ring. The control containing the text seem to be a container for the text view, with its own focus ring. - evgeny
It is a comment. I'm saying that this isn't just a NSTextView in another view. The field editor doesn't have a focus ring. - Willeke

1 Answers

0
votes

I couldn't implement that behavior using the standard controls. My final solution is to put the search field in another custom view with broad margins and implement a custom focus ring drawing.

Here's how my drafty control looks like:

enter image description here