|
|
StringFormatter in IBPalette
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
So, I've made a StringFormatter paletter for interface builder. It lets me use some Fortran formats because it's for formatting an input file to a Fortran program.
Anyways, it doesn't attach to text fields the way the built in NSNumberFormatter does, or like NSDateFormatter.
Does anyone have any idea of what I have to do to get it to attach to a text field?
Code:
@implementation StringFormatterPalette
- (void)finishInstantiate
{
StringFormatter *formy;
formy = [[StringFormatter alloc] initWithLength:30];
[self associateObject:formy ofType:IBWindowPboardType withView:view];
}
@end
@implementation StringFormatter (StringFormatterPaletteInspector)
- (NSString *)inspectorClassName
{
return @"StringFormatterInspector";
}
In the code, view is a custom view used for dragging, and is attached to my view in IB.
I am guessing that I need a special ofType thing, other that IBObjectPboardType. Any ideas? I would like the behavior to match the built in formatters in IB.
(
Last edited by 11011001; Jul 23, 2004 at 07:18 PM.
)
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
Originally posted by 11011001:
I am guessing that I need a special ofType thing, other that IBObjectPboardType. Any ideas? I would like the behavior to match the built in formatters in IB.
The answer was an easy one. I guess I was too tired to see it last night. I found it in IBPalette.h (part of the IB framework).
The required type is:
IBFormatterPboardType
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
The next question I have is, how would I go about detaching the NSFormatter from the NSTextField programatically so that I can implement the detach button?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
Well.. just in case someone ever needs this, I found the answer to remove the formatter.
Code:
- (IBAction)detachFormatter:(id)sender
{
TDStringFormatter *formatter;
id formattedObject;
id <IBDocuments> document;
// get the required objects
document = [NSApp activeDocument];
formatter = [self object];
formattedObject = [document parentOfObject:formatter];
// detach the formatter
[document detachObject:formatter];
// make sure it's not referencing something that doesn't exist now
[formattedObject setFormatter:nil];
[document resetObject:formattedObject];
// update the user interface, and mark the document as dirty
[super ok:sender];
}
I got it from here.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|