Re: Custom palette questions
Re: Custom palette questions
- Subject: Re: Custom palette questions
- From: Hauke Klein <email@hidden>
- Date: Fri, 12 Nov 2004 11:53:51 +0100
On 12.11.2004, at 03:52, E. Wing wrote:
Hello, I've been trying to make a custom palette for one of my OpenGL
views so I can expose some bindings and use it in a more convenient
manner through Interface Builder. But I have a couple of questions
that I can't find documentation about.
First, is it possible to add additional Target/Action or Outlets to my
palette to be exported? For example, I have a Target/Action method I
would like to export called takeBackgroundColorFrom. This method
changes the glClearColor in my specialized OpenGL widget. The idea is
that I want the end user of my palette to be able to connect an
NSColorWell via Target/Action to my palette and change the color. I
want this connection to be available in the actual application (say in
a preferences window), not in the Inspector Panel.
I tried adding an "Action Name" called takeBackgroundColorFrom through
my class inspector, but after everything was built and I tried using
my palette, this action was not displayed. (Only fax and print were
available.)
However, if added the action in the project using the palette (not the
project creating the palette), I was able to call my
takeBackgroundColorFrom method.
So this works, but it requires the end user of the palette to know
that this action exists, and they must enter it manually. I would like
to know if there is a way to automatically export this so the user
need not know about all these things.
The following setup works for my palettes. First of all, you drag the
header containing your view into the nib file containing your palette.
Using the class inspector to add your outlets and actions should do
the same thing, but dragging seems to be simpler. Then, you should
add your class to the array 'ExportClasses' in your palette.table file.
When using the palette, the outlets and actions of your view can be
used with the usual control-dragging. It should not be necessary to
add the action names manually in each nib created with your palette.
My second question is, how I can draw something in my palette so it
isn't just a blank white rectangle. Because my view is a subclass of
an NSOpenGLView, I have defined my drawRect method. But in Interface
Builder, it doesn't seem to render my OpenGL calls. So I get a white
rectangle. I've seen examples of proxy images used for palettes that
are not NSViews, but my palette is an NSView and I have been
unsuccessful at applying non-view those techniques. Can somebody
recommend a solution for this?
Your drawRect: should be called as usual. You might use NSLog() to
verify this (the log messages will appear in the console.log file.) A
potential problem is that no outlets or bindings are set on the view
object in IB. Connected outlets are not recorded in their source objects
but in special objects which will establish the connection after the
nib file was loaded in an application.
You should try to compare your code with the example palettes provided
in /Developer/Examples/InterfaceBuilder, but you probably already did
this.
Hauke
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden