• 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
NSFormatter isPartialStringValid is not being called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSFormatter isPartialStringValid is not being called


  • Subject: NSFormatter isPartialStringValid is not being called
  • From: Ron Wilson <email@hidden>
  • Date: Sat, 7 Jan 2006 13:36:19 -0800

I have a NSFormatter subclass which overrides the standard 3 methods:
- (NSString *)stringForObjectValue:(id)anObject
- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error
- (BOOL)isPartialStringValid:(NSString **)partialStringPtr
proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
originalString:(NSString *)origString originalSelectedRange: (NSRange)origSelRange
errorDescription:(NSString **)error


In a custom NSCell subclass (VCell), I'm using a NSTextFieldCell (editorCell - a member variable) to perform text editing when the user needs to edit certain attributes of the object represented by the VCell.

When I set the NSTextFieldCell formatter to my custom NSFormatter and then call selectWithFrame:inView:editor:delegate:start:length:, only stringForObjectValue: is called. getObjectValue: and isPartialStringValid: are never called.

The code to start editing looks like this:

NSText* editTextObj = [controlView editorForCell:self];
if (editTextObj)
{
[editorCell setObjectValue:[NSNumber numberWithDouble:someDoubleValue]];
[editorCell setControlSize:NSSmallControlSize];
[editorCell setFont:[NSFont controlContentFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
[editorCell setFormatter:myCustomFormatter];
[editorCell selectWithFrame:editFrame inView:controlView editor:editTextObj delegate:controlView start:0 length:-1];
}


Editing does work. The editable text appears in the correct location and accepts keystrokes. All of the NSText delegate methods seem to be called (at least the ones I'm using). textDidEndEditing: is called when Tab or Enter are hit.

The custom formatter stringForObjectValue: method is called and does return a valid string. That string is displayed when the field editor first displays the string. If I remove the call to setFormatter: then editing still works, but the initial value displayed is just what the default formatter would display for the double value that is initially set in setObjectValue:.

Again, I'm trying to figure out why neither getObjectValue: or isPartialStringValid:... are being called.

Any suggestions on how to debug this or why this is happening would be greatly appreciated.

thanks,
Ron
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Saving the text selection with master/detail view and bindings
  • Next by Date: Why do all subcell buttons highlite for custom cell in NSTableView?
  • Previous by thread: Re: NSArrayController insertObject:atArrangedObjectIndex: not working as expected
  • Next by thread: Why do all subcell buttons highlite for custom cell in NSTableView?
  • Index(es):
    • Date
    • Thread