Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > StringFormatter in IBPalette

StringFormatter in IBPalette
Thread Tools
11011001
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Jul 23, 2004, 07:11 PM
 
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. )
     
11011001  (op)
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Jul 23, 2004, 07:34 PM
 
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
     
11011001  (op)
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Jul 23, 2004, 11:51 PM
 
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?
     
11011001  (op)
Mac Elite
Join Date: May 2001
Location: Up north
Status: Offline
Reply With Quote
Jul 26, 2004, 07:42 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 12:59 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,