Re: stop NSSearchField editing selected row in NSOutlineView
Re: stop NSSearchField editing selected row in NSOutlineView
- Subject: Re: stop NSSearchField editing selected row in NSOutlineView
- From: Ken Thomases <email@hidden>
- Date: Sun, 20 Mar 2016 05:12:54 -0500
On Mar 20, 2016, at 4:48 AM, sqwarqDev <email@hidden> wrote:
>
> I have an OutlineView inside a SplitView in an NSPanel.
>
> I've been trying to implement an NSSearchField for the OutlineView. The behaviour I want is simply for the outline view to select the first hit that matches the search term. I've had no problems getting the actual search to work just fine, but the problem is if I hit return again while a row is selected in the outlineView. When that happens, the textField in the row gets edited to whatever the stringValue of the NSSearchField is, including if it's nil (in other words, it will replace the text in the textField in my OutlineView with an empty string).
>
> I've been all round the houses trying to figure this out. I thought initially it was to do with my search code, but in fact the behaviour occurs even if the NSSearchField's target action is an empty stub, and it also occurs even with a regular NSTextField dragged straight out IB's object library.
>
> I have tried various things such as trying to deselect the row in the OutlineView, trying to make the NSSearchField resign FirstResponder, and trying to interfere with the field editor using endEditingFor: Alas, these were all red herrings, and I remain stuck with my problem.
>
> I have determined that when the NSSearchField's action is sent when a row is selected in the outlineView, it is triggering my outlineView's - (NSView*)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item method.
>
> Why would this be? I have not connected the _searchField in IB or in code to the OutlineView, and they do not share the same delegate (in fact with or without a delegate for the _searchField, the undesirable behaviour remains).
>
> How can I stop the NSSearchField from editing the selected row?
You need to provide more details. Ideally, you'd provide a minimal, complete reproducing example. Failing that, how are you configuring things, in detail? What is the selector of the action method? What is the target? Is it a specific object or the responder chain (represented by First Responder in a NIB)?
How are you making the outline view "select" the first match?
I suspect you are doing something that attempts to manipulate the first responder behind the window's back, or without going through the proper methods, and ending up with the field editor that the search field was using somehow now targeting the text field in the outline view row. The field editor has not been reconfigured for that text field, so it still has the content of the search field and, on Return, it sets the text field to have that content.
Show your code.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden