Re: cell-based NSTableView, NSArrayController and first responder

2017-07-12 Thread Martin Hewitson

> On 12 Jul 2017, at 14:32, Ken Thomases  wrote:
> 
> On Jul 12, 2017, at 4:52 AM, Martin Hewitson  
> wrote:
>> 
>> I have a new bug in an application which I believe has only appeared in 
>> 10.12.
>> 
>> I have a cell-based NSTableView backed by an NSArrayController, and the 
>> (new) problem I have is that the editing of a cell ends after the first 
>> keystroke. It looks as if first responder is resigned, but I can’t figure 
>> out why, and as I say, this seems to be new behaviour.
> 
> If you focus the cell again and type, does editing end after _every_ 
> keystroke?  Or can you continue editing properly after that?

Yes, it ends after every keystroke. One has to double click to enable editing 
again, but a single keystroke ends editing.

> 
> Where does focus go?  Is the table view focused?  Or is nothing in the window 
> focused?  For example, if you type an up- or down-arrow key, does it select 
> rows in the table view?

I tried to determine that, but I couldn’t find where it goes. It seems to go 
away from the window.


> 
>> Has anyone else hit this issue and solved it? Or does anyone have any 
>> pointers where to start digging? I reviewed all the bindings and tableview 
>> setup, but I haven’t changed anything here in years.
> 
> Is the array controller set to rearrange its contents automatically based on 
> sort descriptors?  

No.

> Does the table column's value binding have Continuously Updates Value enabled?

Yes.

>  If so and you change that, does the problem go away?

Yes!

> 
> The table view will be the text cell's delegate and will be called for the 
> delegate methods described in the NSControlTextEditingDelegate protocol as 
> well as those described in NSControl.  Try using a custom subclass of 
> NSTableView (if you're not already) and overriding -controlTextDidEndEditing: 
> and -control:textShouldEndEditing: to log [NSThread callStackSymbols] and 
> call through to super (if the static superclass's instances respond to those 
> methods, i.e. [NSTableView instancesRespondToSelector:_cmd]).  The stack 
> trace should give you some idea of what's responsible for removing focus from 
> the cell.
> 
> If the whole table view is losing focus, you could do the same with 
> -resignFirstResponder.

I tried most (if not all) of this, and didn’t have any joy. 

Anyway, the ‘Continuously Updates Value’ setting seems to have done the trick. 
Has something changed in the underlying implementation? As I said, this was 
working fine until recently.

Thanks a lot for the detailed answer! I’m happy it’s fixed, but unhappy that I 
don’t really understand why.

Cheers,

Martin


> 
> Try to reproduce the problem in a new project, adding/changing as little as 
> possible to get it to reproduce.  If you can, try sharing that with us.
> 
> Regards,
> Ken
> 


Dr. Martin Hewitson, Staff Scientist
Institut für Gravitationsphysik der Leibniz Universität Hannover
Callinstraße 38
D-30167 Hannover, Germany
Tel: +49 511 762 17121
Fax: +49 511 762 5861
Email: hewit...@aei.mpg.de


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: cell-based NSTableView, NSArrayController and first responder

2017-07-12 Thread Ken Thomases
On Jul 12, 2017, at 4:52 AM, Martin Hewitson  wrote:
> 
> I have a new bug in an application which I believe has only appeared in 10.12.
> 
> I have a cell-based NSTableView backed by an NSArrayController, and the (new) 
> problem I have is that the editing of a cell ends after the first keystroke. 
> It looks as if first responder is resigned, but I can’t figure out why, and 
> as I say, this seems to be new behaviour.

If you focus the cell again and type, does editing end after _every_ keystroke? 
 Or can you continue editing properly after that?

Where does focus go?  Is the table view focused?  Or is nothing in the window 
focused?  For example, if you type an up- or down-arrow key, does it select 
rows in the table view?

> Has anyone else hit this issue and solved it? Or does anyone have any 
> pointers where to start digging? I reviewed all the bindings and tableview 
> setup, but I haven’t changed anything here in years.

Is the array controller set to rearrange its contents automatically based on 
sort descriptors?  Does the table column's value binding have Continuously 
Updates Value enabled?  If so and you change that, does the problem go away?

The table view will be the text cell's delegate and will be called for the 
delegate methods described in the NSControlTextEditingDelegate protocol as well 
as those described in NSControl.  Try using a custom subclass of NSTableView 
(if you're not already) and overriding -controlTextDidEndEditing: and 
-control:textShouldEndEditing: to log [NSThread callStackSymbols] and call 
through to super (if the static superclass's instances respond to those 
methods, i.e. [NSTableView instancesRespondToSelector:_cmd]).  The stack trace 
should give you some idea of what's responsible for removing focus from the 
cell.

If the whole table view is losing focus, you could do the same with 
-resignFirstResponder.

Try to reproduce the problem in a new project, adding/changing as little as 
possible to get it to reproduce.  If you can, try sharing that with us.

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


cell-based NSTableView, NSArrayController and first responder

2017-07-12 Thread Martin Hewitson
Dear list,

I have a new bug in an application which I believe has only appeared in 10.12.

I have a cell-based NSTableView backed by an NSArrayController, and the (new) 
problem I have is that the editing of a cell ends after the first keystroke. It 
looks as if first responder is resigned, but I can’t figure out why, and as I 
say, this seems to be new behaviour.

Has anyone else hit this issue and solved it? Or does anyone have any pointers 
where to start digging? I reviewed all the bindings and tableview setup, but I 
haven’t changed anything here in years.

Many thanks,

Martin

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com