• 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: What can be in an IB Plugin?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What can be in an IB Plugin?


  • Subject: Re: What can be in an IB Plugin?
  • From: Rick Hoge <email@hidden>
  • Date: Thu, 22 Nov 2007 09:33:45 -0500


Thanks!

I noticed that if I add a library object to an IB 3.x Plugin that is a standard Cocoa object (e.g. an NSPopupButton with some extra configuration) that the class is not displayed in the inspector after I select it - the drop-down list shows NSPopupButton as an option but after I select it the class field is blank. Adding a custom subclass to the linked framework makes this weirdness go away.

Do all added objects *have* to be custom subclasses? What if, as in the above example, I just want a standard NSPopupButton that is pre-populated with a bunch of selections, without requiring a custom subclass. Is the IBPlugin the best way to do this? Many of my intended uses for the plugin definitely require custom subclasses. However in some cases it may be convenient to have some aggregate view collection that requires configuration, and which I want to be consistent in different contexts, but which does not actually require any subclasses.

You can definitely do this. I don't believe I showed that in my sample IB Plug-In code. In my own plug-ins, I often create NSMatrix instances pre-filled with a configured cell. I also then set the prototype cell the same way so that expanding the matrix will create cells with appropriate defaults.

It seems to work, I think I was caught off guard by the strange behavior of the popup for class selection. If you select a class from the drop-down menu, the text field stays blank until you hit tab (at least on my system, which is IB 3.0 (629) on a MacBook Pro at 10.5.1). Will file a bug...


I gather that if a client of the plugin wants to subclass a class provided by the plugin/framework to override or add methods this should be no problem either...

The final thing I am getting my head around is the fact that any configuration changes to the UI items in the Library nib file done in IB won't propagate to other nibs that have already used those items. Functionality provided by the framework will be updated, of course, but if I change the text on an NSButton I'll have to manually update any nib files that have used that button in the past. I would like to make sure that I am understanding this correctly, and not missing any efficient ways to handle this kind of situation.

It sounds like the layout aspects of the IB Plugin should be pretty mature before you start using it in a lot of places...

Thanks again - this info is very helpful, as is the example code now that I understand it better.

Rick

To do this, just drag in anything off of the library into your <MyPlugin>Library.nib file and create a link to it from a library template object.

Note that there's really no end to the possibilities. You can also create nested views (e.g. an NSBox containing 1 or more other views/ controls). Basically, you're just creating shortcuts.


Finally, in the specific case of NSMatrix. If you end up with a custom subclass of NSMatrix, I've found it easiest to provide an implementation of initWithFrame: which does this:


- (id)initWithFrame:(NSRect)aFrame
{
MyCustomOrStandardCell* thePrototypeCell = [[[MyCustomOrStandardCell alloc] init] autorelease];
// or, use initTextCell: or initImageCell:

[thePrototypeCell setSomeAttribute:1];
[thePrototypeCell setSomeOtherAttribute:@"xyz"];


if ((self = [super initWithFrame:aFrame mode:NSRadioModeMatrix / * or whatever mode you need */
prototype:thePrototypeCell numberOfRows:1 numberOfColumns: 1]) != nil)
{
// set any of your custom matrix attributes here
}


    return self;
}

IB will then call initWithFrame: to create an instance of your matrix. When you drag it in, it will be pre-populated with a single cell that matches your prototype.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: What can be in an IB Plugin?
      • From: Ricky Sharp <email@hidden>
References: 
 >What can be in an IB Plugin? (From: Rick Hoge <email@hidden>)
 >Re: What can be in an IB Plugin? (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Build problem (again)
  • Next by Date: strange build issue
  • Previous by thread: Re: What can be in an IB Plugin?
  • Next by thread: Re: What can be in an IB Plugin?
  • Index(es):
    • Date
    • Thread