discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCell bug


From: Andreas Höschler
Subject: Re: NSCell bug
Date: Mon, 26 Feb 2007 17:57:41 +0100

Hi all,

I am still trying to make the latest svn download ready for productive usage (fixing bugs). I am currently working on the following problem. I have a NSTextField with NSNumberFormatter. I have set the delegate of this text field to my controller object and implemented.

- (void)controlTextDidChange:(NSNotification *)obj
{
        NSLog(@"value %@", [valueField objectValue];
}

This logs "value (nil)" when typing numbers into the field.. The problem is that _cell.has_valid_object_value is NO and therefore

- (id) objectValue
{
   if (_cell.has_valid_object_value)
     {
      return _object_value;
     }
   else
     {
      return nil;
     }
}

returns nil. Still investigating when this flag is currently set, but this happens definitely too late. This has worked before the upgrade. Anybody remembers a related change to the tree?

Here is the fix for NSTextField.m:

- (void)textDidChange:(NSNotification *)aNotification
{
   NSFormatter *formatter;

   [self validateEditing]; // <-------- add this

[super textDidChange:aNotification]; // this posts the controlTextDidChange notification // we have to make sure that objectValue is updated before we do that.

   formatter = [_cell formatter];
   if (formatter != nil)
     {
      NSString *partialString;
      NSString *newString = nil;
      NSString *error = nil;
      BOOL wasAccepted;

      partialString = [_text_object string];
      wasAccepted = [formatter isPartialStringValid: partialString
                                   newEditingString: &newString
                                   errorDescription: &error];

      if (wasAccepted == NO)
        {
SEL sel = @selector(control:didFailToValidatePartialString:errorDescription:);

         if ([_delegate respondsToSelector: sel])
           {
[_delegate control:self didFailToValidatePartialString:partialString errorDescription: error];
           }
        }

      if (newString != nil)
        {
         NSLog (@"Unimplemented: should set string to %@", newString);
          // FIXME ! This would reset editing !
          //[_text_object setString: newString];
        }
      else
        {
         if (wasAccepted == NO)
           {
              // FIXME: Need to delete last typed character (?!)
NSLog (@"Unimplemented: should delete last typed character");
           }
        }
     }
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]