Re: controlTextDidEndEditing vs controlTextDidChange
Re: controlTextDidEndEditing vs controlTextDidChange
- Subject: Re: controlTextDidEndEditing vs controlTextDidChange
- From: Brian Webster <email@hidden>
- Date: Mon, 3 Jun 2002 09:51:39 -0500
On Monday, June 3, 2002, at 06:28 AM, cocoa-dev-
email@hidden wrote:
For example, if I attach a delegate to a field, and watch the
Text Did change
notification, I get called everytime any part of string
changes. This sounds
fine, but what if I want to post an Undo event for every text
change. I do
not want 10 events to undo when someone types in a 10 char
string. I want
just one event, when string is completed. So I can watch
controlTextDidEndEditing. But that is only called when focus changes to
another field. It is not called for important actions like
saving document,
or selecting menu item, ie. actions that really do indicate the
user is done
typing some text.
For implementing undo, I would use the
controlTextDidEndEditing. If you're concerned about changes
being committed at other times such as before saving a document,
you can just end the editing session yourself before such an
operation. Do this by calling endEditing: on the text field's
cell, passing in the window's field editor as the NSText
argument. This should in turn trigger the delegate method, so
you can put the next text into your document's data before going
through with the save operation.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.