• 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: Ricky Sharp <email@hidden>
  • Date: Thu, 22 Nov 2007 08:17:49 -0600


On Nov 22, 2007, at 7:33 AM, Rick Hoge wrote:


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.


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: Rick Hoge <email@hidden>
References: 
 >What can be in an IB Plugin? (From: Rick Hoge <email@hidden>)

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