Formatter, delegate for NSMatrix with NSTextFields
Formatter, delegate for NSMatrix with NSTextFields
- Subject: Formatter, delegate for NSMatrix with NSTextFields
- From: Andrew White <email@hidden>
- Date: Fri, 05 Nov 2004 13:00:03 +1100
I have an NSMatrix containing 6 NSTextFields. I want to apply a single
formatter to all elements of the field, and also catch textDidEndEditing
events for any element (at which point I recalcaluate a large array).
I did consider using bindings rather than respond to textDidEndEditing, but
as far as I can tell I'd have to set up a separate rule for each line of my
array (all lines are independent), whereas by catching an event I can use
array indexing, saving a lot of code.
What I've done:
In IB: created an NSNumberFormatter in the nib, and attached it to the
'formatter' outlet of the NSMatrix.
In the NSDocument subclass:
- (void) makeWindowControllers
{
MyWindowController * ctl =
[ [MyWindowController alloc]
initWithWindowNibName: [self windowNibName]
];
[ctl autorelease ];
[self addWindowController: ctl ];
}
In MyWindowController, override textDidEndEditing.
In IB: Set type of FilesOwner to MyWindowController.
In IB: Set delegate of NSMatrix to File's Owner.
However, no formatting is done on entries, and the textDidEndEditing method
is not called. Obviously I'm doing both these things wrongly.
What is the correct way to do this?
I note that each NSTextFieldCell has it's own formatter. I certainly don't
want to set these manually in IB, though I'm willing to do it
programmatically on window load if I have to.
I can't find a delegate field in the NSTextFieldCells in IB, so I don't
know if I can attach the delegate directly to the cells, even if I wanted to.
Thanks
--
Andrew White
_______________________________________________
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