FROM : Lieven Dekeyser
DATE : Tue Jan 29 11:56:31 2008
On 28 Jan 2008, at 23:35, Quincey Morris wrote:
> On Jan 28, 2008, at 13:11, Lieven Dekeyser wrote:
>
>> In my app, I have a basic login form: username field, password field
>> and login button. The username and password fields' values are bound
>> to a custom controller that saves the values after editing. When the
>> login button is clicked, the username and password are fetched from
>> the custom controller.
>>
>> ...
>>
>> Is there any way to make sure the password field's editor ends when
>> the user clicks on a button?
>
>
> Assuming you mean "custom controller" in the MVC sense, I think all
> you need to do is to insert a suitable NSController
> (NSObjectController, I expect) into your NIB file and connect the
> text fields to their contents through it. Here's a quote from the
> Cocoa document "Cocoa Bindings Programming Topics", section "What
> Are Cocoa Bindings?", subsection "Why Are NSControllers Useful?":
>
> --
> "NSController (and Application Kit user interface elements that
> support binding) implements the NSEditor and NSEditorRegistration
> protocols. The NSEditorRegistration protocol provides a means for an
> editor (a view) to inform a controller when it has uncommitted
> changes. The NSEditor protocol provides a means for requesting that
> the receiver commit or discard any pending edits.
>
> "For example, if a user is typing in a text field and then clicks a
> button, the controller ensures that the model object is updated with
> the complete contents of the text field before the button action
> takes place.
>
> "Although the methods are typically invoked on user interface
> elements by a controller they can also be sent to a controller, for
> example in response to a user’s attempt to save a document or quit
> an application."
> --
>
> The middle paragraph is the one that promises to do for free what
> you are asking.
Unfortunately, it doesn't seem to be working as advertised. When I use
an NSObjectController, I still have to call -commitEditing on it when
the button is clicked, otherwise my model is not updated... I'd expect
NSTextField to lose focus and commit automatically when the user
clicks a button, but the field doesn't seem to lose focus...
--Lieven_______________________________________________
Cocoa-dev mailing list (<email_removed>)
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:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
This email sent to <email_removed>
DATE : Tue Jan 29 11:56:31 2008
On 28 Jan 2008, at 23:35, Quincey Morris wrote:
> On Jan 28, 2008, at 13:11, Lieven Dekeyser wrote:
>
>> In my app, I have a basic login form: username field, password field
>> and login button. The username and password fields' values are bound
>> to a custom controller that saves the values after editing. When the
>> login button is clicked, the username and password are fetched from
>> the custom controller.
>>
>> ...
>>
>> Is there any way to make sure the password field's editor ends when
>> the user clicks on a button?
>
>
> Assuming you mean "custom controller" in the MVC sense, I think all
> you need to do is to insert a suitable NSController
> (NSObjectController, I expect) into your NIB file and connect the
> text fields to their contents through it. Here's a quote from the
> Cocoa document "Cocoa Bindings Programming Topics", section "What
> Are Cocoa Bindings?", subsection "Why Are NSControllers Useful?":
>
> --
> "NSController (and Application Kit user interface elements that
> support binding) implements the NSEditor and NSEditorRegistration
> protocols. The NSEditorRegistration protocol provides a means for an
> editor (a view) to inform a controller when it has uncommitted
> changes. The NSEditor protocol provides a means for requesting that
> the receiver commit or discard any pending edits.
>
> "For example, if a user is typing in a text field and then clicks a
> button, the controller ensures that the model object is updated with
> the complete contents of the text field before the button action
> takes place.
>
> "Although the methods are typically invoked on user interface
> elements by a controller they can also be sent to a controller, for
> example in response to a user’s attempt to save a document or quit
> an application."
> --
>
> The middle paragraph is the one that promises to do for free what
> you are asking.
Unfortunately, it doesn't seem to be working as advertised. When I use
an NSObjectController, I still have to call -commitEditing on it when
the button is clicked, otherwise my model is not updated... I'd expect
NSTextField to lose focus and commit automatically when the user
clicks a button, but the field doesn't seem to lose focus...
--Lieven_______________________________________________
Cocoa-dev mailing list (<email_removed>)
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:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Lieven Dekeyser | Jan 28, 22:11 | |
| Kyle Sluder | Jan 28, 22:45 | |
| Quincey Morris | Jan 28, 23:35 | |
| Lieven Dekeyser | Jan 29, 11:56 | |
| Kyle Sluder | Jan 29, 19:36 | |
| Quincey Morris | Jan 29, 19:39 | |
| Lieven Dekeyser | Jan 30, 16:09 |






Cocoa mail archive

