Re: Calling commitEditing text field loses focus

Christiaan Hofman <[email protected]> Wed, 21 Dec 2011 17:50:49 +0100
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Dec 21, 2011, at 17:32, Jim Correia wrote:

> On Dec 21, 2011, at 8:28 AM, Christiaan Hofman wrote:
>=20
>> This makes no sense to me. An NSController does not even have *any* =
properties, let alone a window. It's not an interface element. And =
NSObjectController only knows (publicly) about things it binds to (its =
content or selection), but what is needed is the objects that bind *to* =
it. There's no API for that. So I really fail to see how you could have =
done this without using SPI.
>=20
> You=92ve got two options here:
>=20
> You know where you use the controller, so you can associate one or =
more windows with your controller. (It doesn=92t have any built-in =
properties to track this association=97you=92ll have to add this.)
>=20
> Or, you can just snapshot the first responder and state for every =
window, commit editing, and restore it in those windows where it has =
changed.
>=20
> For my purposes, the latter performed perfectly acceptably (having =
hundreds of windows open isn=92t a typical use case), so that was the =
solution that I wrote.
>=20
> Jim

Sounds like overkill to me. I guess as one has to write and call a =
custom method for this anyway that one can just as well pass the =
relevant window as an argument to that method =
-(BOOL)commitEditingAndRestoreFirstResponderForWindow:(NSWindow =
*)aWindow.

Christiaan