Creating a NSView with Interface Builder
-
Hello,
i'm currently working on a Plugin. My problem is that i have to
provide a preference View. I have to give a NSView to the programm.
Currently i wrote a NSView Subclass, but its to much work to do every
button an textfield by code. My question is, how can I design an View
in Interface Builder an give the result as an NSView to an other object.
I hope you understand my problem
thanks
thomas -
On Feb 25, 2008, at 4:41 PM, Herr Thomas Bartelmess wrote:> Hello,
> i'm currently working on a Plugin. My problem is that i have to
> provide a preference View. I have to give a NSView to the programm.
> Currently i wrote a NSView Subclass, but its to much work to do
> every button an textfield by code. My question is, how can I design
> an View in Interface Builder an give the result as an NSView to an
> other object.
Hi Thomas,
Yes, this is something popular to do. Here is what I've done for
plugins...
- Create a window controller class in the plugin
- Create a IBOutlet that is connected to an NSView (in the plugin's NIB)
- During runtime, instantiate that window controller (when you
instantiate the plugin) in the main app.
- From within the main app, query the the plugin's window controller
for the IBOutlet NSView, and add it to the app's master view.
- If you are creating an app that has multiple plugins, you can simply
remove the previous subview from the master view each time a different
plugin is selected in the app.
hope that helps,
Jaime Magiera
Sensory Research
http://www.sensoryresearch.net -
> Hello,
> i'm currently working on a Plugin. My problem is that i have to
> provide a preference View. I have to give a NSView to the programm.
> Currently i wrote a NSView Subclass, but its to much work to do every
> button an textfield by code. My question is, how can I design an View
> in Interface Builder an give the result as an NSView to an other
> object.
>
> I hope you understand my problem
> thanks
> thomas
I've done that many times and it is not too complicated. In my case, a
contol palette of the main app
has different tab views. One of these must show content provided by
the plugin that is presently enabled
(I implement a fit procedure where the main app provides the
calculating engine and different
plugins specify the functions to be used). With my approach you create
within your plug-in a NIB file containing a custom view (there is even
a template for this purpose in IB vers. 3)
and a controller class (I'd say, subclassing NSWindowController) for
that view.
This class should be the owner of the NIB file and contain all
outlets / actions pertaining to it.
Its init routine should have the superview of the view you want to
show (in my case, the empty tab view
of the palette) as a parameter (some event in
the main program triggers the principal class of your plug-in, which,
in turn, starts your controller).
The controller class loads the NIB file and inserts the view in its
superview. Then, it manages every
user interaction through the controls located within the view.
I hope I've given you an idea. If not, I might send you some snippet.
Andrea -
At 18:24 -0800 25/02/08, <cocoa-dev-request...> wrote:> From: Herr Thomas Bartelmess <thomas.bartelmess...>
> Date: Mon, 25 Feb 2008 22:41:25 +0100
> Message-ID: <4FB26557-5D79-414A-B58D-A66A4E7599B0...>
>
> i'm currently working on a Plugin. My problem is that i have to provide a preference View. I have to give a NSView to the programm. Currently i wrote a NSView Subclass, but its to much work to do every button an textfield by code. My question is, how can I design an View in Interface Builder an give the result as an NSView to an other object.
Thomas,
Somewhat late to this thread, but if you go to
http://www.brockerhoff.net/pap.html
and download the first paper in the list ("Plugged-In Cocoa"), you'll see detailed instructions and a sample project. It's from 2002 but everything should still work.
Gut Glück,
--
Rainer Brockerhoff <rainer...>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php


