0
//1:
-(void) TextFieldEdit:(CDTextField *)textField{
 [textField setEditable:YES];
}

//2:
 - (void)controlTextDidEndEditing:(NSNotification *)aNotification{
 NSTextField* textField = (NSTextField *)[aNotification object];
 [textField setEditable:NO];
}

I hope setEditable at time 1, and close it at time 2.

But I found when I sent setEditable Xcode immediately called the controlTextDidEndEditing:.

Why?

EDIT: The first method is invoked via the following sub-classed method:

-(void)mouseDown:(NSEvent *)event {
if ([event type]==1)
{
NSInteger key=[event modifierFlags];
if ( key & NSCommandKeyMask)
    {[self.delegate CDTextFieldEdit:self]; }
else
    if (event.clickCount >1)
    {[self.delegate CDTextFieldClicked:self]; return;}

 }
 [super mouseDown:event];
 }
alexwlchan
  • 5,699
  • 7
  • 38
  • 49
DaoYan.Tang
  • 77
  • 1
  • 6
  • *How* is the first method being called? – trojanfoe Jun 18 '13 at 10:02
  • I subclassed it with CDTEXTField instead NSTEXTField. -(void)mouseDown:(NSEvent *)event { //[super mouseDown:event]; if ([event type]==1)// { NSInteger key=[event modifierFlags]; //& ( key & NSAlternateKeyMask) & (key & NSControlKeyMask)) if ( key & NSCommandKeyMask) {[self.delegate CDTextFieldEdit:self]; } else if (event.clickCount >1) {[self.delegate CDTextFieldClicked:self]; return;} } [super mouseDown:event]; } – DaoYan.Tang Jun 18 '13 at 14:08
  • Please edit your question appropriately. I have a query about what looks like a spurious comment (`//`). – trojanfoe Jun 18 '13 at 14:43

0 Answers0