NSTextField over NSOpenGLView

2019-03-18 16:33发布

I have made a window with an NSOpenGLView that I am rendering openGL content into.

I want to add some buttons and text fields to the view: I can add NSTextFields and NSButtons using interface builder (or code) but they do not appear.

NSOpenGLView is documented as not being able to have sub views, so I then made my own CustomGLView by deriving directly from NSView and implementing the code to create and use a NSOpenGLContext in it. But the subviews are still not appearing :- the OpenGL context paints over them.

On Windows this problem does not exist:- Windows used to host OpenGL MUST have the WS_CLIPCHILDREN and WS_CHIPSIBLINGS styles set ensuring that any peer, or sub children (views) will not be obscured by the OpenGL surface.

How do I get subviews to display over a NSView thats drawing using OpenGL ?

7条回答
Rolldiameter
2楼-- · 2019-03-18 17:11

Simply call -setWantsLayer:YES on the subviews of the NSOpenGLView.

查看更多
登录 后发表回答