Hi all,

*NSControl*
The delegate of an NSControl should be able to access validated values
with objectValue in -controlTextDidChange:(NSNotification *)obj (at
least that's the behavior on MacOSX).

- (void)textDidChange: (NSNotification *)aNotification
{
NSMutableDictionary *dict;

// validate NSNumbers immediately so that objectValue returns reasonable
values in controlTextDidChange:
if ([_cell isEntryAcceptable:[[aNotification object] text]])
{
[self validateEditing];
}


...
}


Here I would like to get some evidence that this is what Cocoa does. You
could for example place a break point in validateEditing and see from
where it gets called.

On MacOSX valdiateEditing is called from here:

#0  0x9313e878 in -[NSControl validateEditing] ()
#1  0x931400b8 in -[NSActionCell attributedStringValue] ()
#2  0x930bb6a8 in _NXDrawTextCell ()
#3  0x930c8180 in -[NSTextFieldCell drawInteriorWithFrame:inView:] ()

Until this is properly figured out, I have changed the above method (temporary hack) as follows, since the above caused problems with date formatters.

- (void)textDidChange: (NSNotification *)aNotification
{
   NSMutableDictionary *dict;

// validate NSNumbers immediately so that objectValue returns reasonable values in controlTextDidChange: if ([(NSFormatter *)[_cell formatter] isKindOfClass:[NSNumberFormatter class]])
     {
      [self validateEditing];
     }

    ...
}

Regards,

  Andreas



_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to