Re: Editing multiple selections with bindings
Re: Editing multiple selections with bindings
- Subject: Re: Editing multiple selections with bindings
- From: Keary Suska <email@hidden>
- Date: Thu, 03 Jan 2013 22:18:50 -0700
On Jan 3, 2013, at 3:53 PM, Patrick Cusack wrote:
> Keary,
>
> I am checking whether or not the user is trying to edit multiple items in my delegate's - (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
>
> If the choose to not complete editing, I should be able to discard editing on the bound NSArrayController, but my control still has focus after calling discardEditing.
Yes--discard/commit editing does only that--it won't change focus/first responder as that is the responsibility of the window, IIRC. You will have to decide what to do next, as you are interrupting the "normal" flow of events. What you do depends on the user experience you want. You could call [window makeFirstResponder:[[window firstResponder] nextResponder]], which should work predictably if you have set the next responder for all applicable editable controls. Alternatively you could just pass nil and end all editing. The latter may make more sense for the detail view, as I assume the decision might apply to every field...
> On Jan 2, 2013, at 9:10 PM, Keary Suska wrote:
>
>> On Jan 2, 2013, at 7:29 PM, Patrick Cusack wrote:
>>
>>> Ok, I do have a delegate for my controls and am currently using control:textShouldEndEditing:. If I return no, however, my control still has focus, and I can't think of a programmatic way to lose focus without committing changes.
>>
>> You would call -discardEditing on the NSObjectController that should be managing the detail interface.
>>
>>> On Jan 2, 2013, at 5:20 PM, Keary Suska wrote:
>>>
>>>> On Jan 2, 2013, at 9:59 AM, Patrick Cusack wrote:
>>>>
>>>>> Sorry, I might not be clear. I have a table view that is bound to an NSArraryController. I want users to be able to edit single and multiple selections from a detail view that has NSTextfields and ComboBoxes. There are occasions where users forget that they have selected multiple items and proceed to edit cues, unaware that they are actually mutating more than one row of data. When an editor tabs into a control like the NSTextField or NSComboBox, I want to give them a chance to discard editing. I can easily deduce that multiple items in my NSArrayController are selected, throw an NSRunAlert, and give users an option to make a choice, but at that point, I have already entered focus into the control and any attempt to leave that control will still change the selected items. I tried overriding acceptsFirstResponder, and conducting my test in that selector, but acceptsFirstResponder gets called more than once, and then the control passes focus onto the next control in the kew view loop. Really what I want to a accomplish is to discard the editing and resign focus from the control.
>>>>
>>>> No--my error--you did say that you are editing in a detail interface. The only thing I can think of is to register a controller as the delegate for the detail fields, then you have access to control:textShouldEndEditing: and friends (look for the NSControlTextEditingDelegate protocol in the docs). All NSControl subclasses use these so it should work for your combo boxes as well.
>>>>
>>>>> On Jan 2, 2013, at 6:41 AM, Keary Suska wrote:
>>>>>
>>>>>> On Jan 2, 2013, at 12:05 AM, email@hidden wrote:
>>>>>>
>>>>>>> I have an application where a user can select multiple rows of data from an NSArrayController and edit those rows from a detail view. Now, there are cases where users have inadvertently changed the values for multiple rows of data when they did not intend to. How can I warn a user when they enter a texfield or nscombobox that they are about to edit multiple rows of data and gracefully give them a way to back out? I noticed that there is no way to discard editing when in a textfield. Is that the case? I am using the control: textShouldEndEditing: delegate method which allow me to get 90% of the way there, but the textfield retains focus, and I can not tab out of the field without getting my warning. Ideally, pressing "esc" should allow me to discard any editing and make the field lose focus.
>>>>>>
>>>>>> IIRC you can set a delegate to the table view and implement tableView:shouldEditTableColumn:row:, and you should be able to prevent editing from even starting until the user has confirmed.
>>
>>
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>>
>
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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