• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting A Changed Cell When Editing Ends
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting A Changed Cell When Editing Ends


  • Subject: Re: Detecting A Changed Cell When Editing Ends
  • From: Jonathan Jackel <email@hidden>
  • Date: Sun, 22 Dec 2002 20:36:33 -0500

It's pretty simple, as Mike explained earlier. This code in the delegate
(plus accessors for lastEditedControl) will "do stuff" when the user changes
a text field (or matrix) AND finishes editing.

- (void)controlTextDidChange:(NSNotification *)aNotification
{
[self setLastEditedControl:[aNotification object]];
}

- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
if ([aNotification object] == lastEditedControl)
{
//do stuff
}
}

In my case, it does not matter if the user edits the control, then changes
it back to what it was before. I simply wanted to avoid constantly updating
values in the UI, which seemed like a very jarring user experience. If
someone wanted to make sure the user changed the value, it seems like you
would want to capture the object value in controlTextShouldBeginEditing: and
compare it to the value in controlTextDidEndEditing:.

Jonathan

on 12/22/02 4:26 PM, David Rio Vierra at email@hidden wrote:

> Have you tried storing the previous value of the control text and
> comparing/updating it in controlTextDidEndEditing: ? Something like
> this:
>
> -(void)controlTextDidEndEditing:(NSNotification *)note
> {
> NSString * newText = [[note object] stringValue];
> if( ! [newText isEqualToString:_oldText] ) // _oldText is an ivar
> initialized to @"" {
> [_oldText release];
> _oldText = [newText retain];
> // respond to changed text
> }
> }
>
> - Rio
>
> On Sunday, December 22, 2002, at 05:30 AM, Jonathan Jackel wrote:
>
>> I want to know when a text field cell ends editing AND has been
>> changed.
>>
>> controlTextDidChange: fires off a notification with every keystroke.
>> I only
>> want to know about the change when editing ends.
>>
>> controlTextDidEndEditing: notifies me when editing ends, whether the
>> cell
>> has changed or not. I want to know whether the cell has changed.
>>
>> Can someone point me in the right direction?
>>
>> Jonathan
>> _______________________________________________
>> 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.
> _______________________________________________
> 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.
_______________________________________________
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.

References: 
 >Re: Detecting A Changed Cell When Editing Ends (From: David Rio Vierra <email@hidden>)

  • Prev by Date: Re: Linker warning with Dec 02 tools
  • Next by Date: Re: how to make version info appear in Finder?
  • Previous by thread: Re: Detecting A Changed Cell When Editing Ends
  • Next by thread: Re: Detecting A Changed Cell When Editing Ends
  • Index(es):
    • Date
    • Thread