Re: How to make key shortcuts and mouse click trigger controlTextDidEndEditing:
Re: How to make key shortcuts and mouse click trigger controlTextDidEndEditing:
- Subject: Re: How to make key shortcuts and mouse click trigger controlTextDidEndEditing:
- From: James Housley <email@hidden>
- Date: Sat, 5 Mar 2005 18:33:09 -0500
On Mar 5, 2005, at 4:50 PM, Erik M. Buck wrote:
This is a variant of a FAQ. Please see the archives:
http://www.cocoabuilder.com/archive/message/2004/11/15/121675
In whatever action method is called by your menu items or other
controls,
call the following code taken directly from Apple's documentation:
if ([myWindow makeFirstResponder:myWindow]) {
// All fields are now valid; it's safe to use
fieldEditor:forObject: to
claim the field editor.
}
else
{ // Force first responder to resign.
[myWindow endEditingFor:nil];
}
See also: - fieldEditor:forObject:, -
windowWillReturnFieldEditor:toObject:
You can call this at the start of your document saving code to
finalize the
editing of any field that might have the user's focus.
From Apple's Documentation:
endEditingFor:
- (void)endEditingFor:(id)anObject
Forces the field editor, which anObject is assumed to be using, to
give up
its first responder status, and prepares it for its next assignment.
If the
field editor is the first responder, it's made to resign that status
even if
its resignFirstResponder method returns NO. This forces the field
editor to
send a textDidEndEditing: message to its delegate. The field editor is
then
removed from the view hierarchy, its delegate is set to nil, and it's
emptied
of any text it may contain.
This method is typically invoked by the object using the field editor
when
it's finished. Other objects normally change the first responder by
simply
using makeFirstResponder:, which allows a field editor or other object
to
retain its first responder status if, for example, the user has
entered an
invalid value. The endEditingFor: method should be used only as a last
resort
if the field editor refuses to resign first responder status. Even in
this
case, you should always allow the field editor a chance to validate
its text
and take whatever other action it needs first. You can do this by first
trying to make the NSWindow the first responder:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Thanks, the [window makeFirstResponder:nil] is the most elegant
solution to tiggering end of editing, but it doesn't solve the second
half of my problem. That was/is after the save the document is still
marked as being modified even though I call [self
updateChangeCount:NSChangeCleared] at the bottom of the save routine.
Would the be solved by going to be based on NSObject and handling the
undo/edited myself.
Jim
--
/"\ ASCII Ribbon Campaign .
\ / - NO HTML/RTF in e-mail .
X - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden http://www.FreeBSD.org The Power to Serve
email@hidden http://www.TheHousleys.net
---------------------------------------------------------------------
Do not meddle in the affairs of dragons, for you are crunchy and taste
good with ketchup.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden