NSTextField通过NSOpenGLView [英] NSTextField over NSOpenGLView

查看:232
本文介绍了NSTextField通过NSOpenGLView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想添加一些按钮和文本字段到视图:我可以添加NSTextFields和NSButtons使用接口构建器(或代码),但它们不出现。



NSOpenGLView被记录为不能够有子视图,所以我制作了我自己的CustomGLView通过直接从NSView派生并实现代码来创建和使用NSOpenGLContext。



在Windows上,这个问题不存在: - 用于托管OpenGL的Windows必须具有 WS_CLIPCHILDREN WS_CHIPSIBLINGS 样式集,确保任何对等体或子子项(视图)不会被OpenGL表面遮蔽。 / p>

如何让子视图显示在使用OpenGL绘制的NSView上?

解决方案

您有两个选择:


  1. 只为文本字段创建一个窗口。添加为承载OpenGL视图的子窗口。


  2. 设置您的视图层次结构,如下所示:




    • 层 - 检视


      • / li>


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 ?

解决方案

You have 2 choices:

  1. Create a window just for the text field. Add as a child window of the one hosting the OpenGL view. Major downside is you have to manage positioning it correctly if the Open GL view is moved.

  2. Set up your view hierarchy like so:

    • Layer-backed view
      • Layer-hosting view whose layer contains an OpenGL layer
      • Text field

这篇关于NSTextField通过NSOpenGLView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆