objective c - NSTableCellView / NSTextField did end editing notification -- without text change? -


how can notification when textfield has ended editing (enter key pressed, clicked outside text field, clicked inside same column, outside text field, etc)

i checked

- (void)textdidendediting:(nsnotification *)anotification {    //some code here } 

but notification called when text has changed. need notified if no text changes have been made.

edit: sort of notification first responder has changed work well.

any ideas?

observe firstresponder state of window …

… [thewindow addobserver:self forkeypath:@"firstresponder" options:nskeyvalueobservingoptionold context:null]; … 

… , read field editor's delegate:

- (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context {   if ([keypath isequaltostring:@"firstresponder"])   {     nsresponder *oldresponder =change[nskeyvaluechangeoldkey];     if ([oldresponder iskindofclass:[nstextview class]])     {       nstextview *editor = (nstextview*)oldresponder;       nstextfield *textfield = (nstextfield*)editor.delegate;       nslog(@"this text field lost focus: %@", textfield.identifier);     }   } } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -