Need advice on OpenGLView behaving like a control
Need advice on OpenGLView behaving like a control
- Subject: Need advice on OpenGLView behaving like a control
- From: Thomas Lachand-Robert <email@hidden>
- Date: Sun, 24 Mar 2002 16:19:25 +0100
Hi all,
I need advice on how to make a NSOpenGlView behave like a control. This is
a 3D control (a little bit similar to Ben Haller CircularSlider if you
know it -- otherwise try it at
http://www.sticksoftware.com/ --, but in 3D)
. For rendering the control itself, I need OpenGL so, my class is as
follows:
@interface TLRArcBall : NSOpenGLView {
@private
IBOutlet id target;
IBOutlet SEL action;
//some more...
}
- (id)initWithFrame:(NSRect)frameRect;
- (id)target;
- (void)setTarget:(id)anObject;
- (SEL)action;
- (void)setAction:(SEL)aSelector;
// etc.
@end
This works as expected EXCEPT I can't set the action in Interface Builder
(the IBOutlet SEL is ignored), something I really would like to do (I LOVE
to do most things in IB ;-))
But I really don't know how to. Here are some possibilities coming to my
mind:
1/ Have TLRArcBall inherits from NSControl, and attach a NSOpenGLContext
to it. It's said in the doc that's how the NSOpenGlView does work, but
that's not very explicit. Is it enough to create the context and then says
[context setView:self]?
2/ Have IB recongize the IBOutlet SEL action. Is there a way to do that?
3/ Put an openGlView inside the control view. Looks like a lot of overhead
for this little improvment.
4/ Ask the clever guys is there is a better solution.
For the moment I choose 4 :->
P.S.: About IB and NSOpenGLView, there is something I don't understand
here. I suspect a bug in IB. If you put a subclass of NSOpenGLView in a
window in IB by first dragging the "OpenGL View" proxy, then changing its
class, then the initWithFrame: method is never called for this object.
Actually none of the init method of NSOpenGLView (I tried init,
initWithEncoder:, initWithFrame:, initWithFrame:withPixelFormat:) is!
There is no problem if you first drag the "Custom View" proxy, then change
its class (here initWithFrame: is called as expected). Any guess?
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
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.