• 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
Re: Framework Classes in IB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Framework Classes in IB


  • Subject: Re: Framework Classes in IB
  • From: Chris Giordano <email@hidden>
  • Date: Thu, 2 Jan 2003 11:51:28 -0500

mw,

I think the issue that you're running into is that IB doesn't know how to archive or unarchive your class. Dragging in the header lets it know about what the class can do, but doesn't help IB to create and handle instances of your class. Unfortunately, I don't know of a way to do this other than making an IB Palette. However, I don't think that your situation is too complex.

I'm certainly what could be classified as a newbie when it comes to IB Palettes and the like, having created a total of 1 in my adult life (although it does have some interesting quirks above and beyond the normal), but I don't think this would be that complex of a project give your description.

Depending on what your class inherits from, it could be something as simple as using some image in your palette, and then creating an instance of your class and inserting it into the target view.

First, check out the examples in /Developer/Examples/InterfaceBuilder/, in particular, the BusyPalette example.

Second, the following is the code that I use (somewhat annotated) that takes an image and dumps a view in place of the image that is dragged from the palette. If you look, you'll see it is pretty clearly "borrowed" from the BusyPalette example. And actually, the image currently isn't dropped in the right location, but I just haven't had a chance to look at that and fix it. I also have had some issues with subviews of my palettized objects being enabled, but I have a feeling that may have something to do with the interesting quirk that I referred to above -- that is, that the inspector for one of the palette objects uses another of the palette objects, so I have some interesting circularity issues with builds. That, and some significant coding changes.

In any case, here is how I deposit my object in my IBPalette subclass:

- (void)depositViewResourceFromPasteboard:(NSPasteboard *)pasteboard
onObject:(id)object atPoint:(NSPoint)point
{
id <IBDocuments> document;
NSArray* pasteboardObjects;

document = [NSApp documentForObject:object];
pasteboardObjects = [document pasteType:CMGDateWidgetPboardType fromPasteboard:pasteboard parent:object];

if ([pasteboardObjects count] > 0) {
CMGDateControlInspectWidget * cell;

cell = [pasteboardObjects objectAtIndex:0];
if ([object respondsToSelector: @selector(addSubview:)])
{
// calculate new frame for dateWidget
NSRect newRect;

// calculate new frame and set newRect

[cell setFrame:newRect];
[object addSubview:cell];
}
}
}

Overall, I don't think this would be an ordeal to create and palettize your object. Given that you have your code in a framework, you're already much of the way there.

Hope I'm not totally off base and this helps a little. Sorry it isn't the answer you were looking for.

chris

On Tuesday, December 31, 2002, at 05:18 PM, mw wrote:

I now (finally) have a working rollover button class that I can use in my
software. So to make sure I compiled it (as a framework) correctly, I made a
little project that used the class (just a one window, 2 control interface
that demonstrated that the class works). But I've come across a problem. If
I want to have an instance of this class in my nib file (since it is a
button, after all), I figured that I could just drag the header file that
defined the class from the framework in the little project into IB and then
set the Custom Class of the button to NPRolloverButton (the name of the
class).

This seems to work at first, as I can import the class and set the button to
that class. But whenever I try to run the program, I get this error followed
by the program exiting from Signal 5 (SIGTRAP):

2002-12-31 17:16:08.976 Rollover Class Demo[1068] Unknown class
NPRolloverButton in Interface Builder file.

I also get 3 more errors telling me that the selectors that are implimented
in this class aren't recognized (the reasons for this are obvious):

2002-12-31 17:16:09.222 Rollover Class Demo[1068] *** -[NSImageView
setController:]: selector not recognized

So, my question is: is there any way to import a class from a framework into
IB without having to make a whole IB palette or whatever? I would really
like to avoid that if possible (it is just too complex for something as
small as this).

TIA,
mw
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Symbol font
  • Next by Date: Re: Symbol font
  • Previous by thread: Re: loading windows & SIGBUS
  • Next by thread: Selected menu bar pattern?
  • Index(es):
    • Date
    • Thread