NSView子类中的鼠标单击事件

编程入门 行业动态 更新时间:2024-10-27 02:28:15
本文介绍了NSView子类中的鼠标单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个用OpenGL上下文初始化的NSView子类,并且具有大量鼠标事件处理(onMouseDown等).我有一个使用它的应用程序,该应用程序具有一个包含视图的可可主窗口,并且所有鼠标事件均正常工作.

I have an NSView subclass that gets initialized with an OpenGL context and has a bunch of mouse event handling (onMouseDown, etc...). I have an app using it which has a main Cocoa window that contains the view and all the mouse events are working properly.

但是,我现在尝试在另一个应用程序中使用它,在该应用程序中,我有一个辅助窗口弹出并用视图初始化,并且当我将鼠标移动到evets时,我似乎没有任何鼠标单击(或键盘)事件.

However, I'm trying to use it now in another app where i have a secondary window that pops open and gets initialized with the view and while i get mouse moved evets, I don't seem to get any mouse click (or keyboard for that matter) events whatsoever.

当我单击并拖动视图时,整个窗口都会移动,我想这是为什么我没有得到任何鼠标事件的原因.我有acceptsFirstResponder和acceptsFirstMouse返回YES,甚至有hitTest返回self来获得良好的测量结果.

When I click and drag on the view, the entire window moves, which im guessing has to do why i dont get any mouse events. I have acceptsFirstResponder and acceptsFirstMouse returning YES and even have hitTest returning self for good measure.

你们有什么主意吗?

推荐答案

您需要从NSView子类中的-mouseDownCanMoveWindow返回NO.

You need to return NO from -mouseDownCanMoveWindow in your NSView subclass.

更多推荐

NSView子类中的鼠标单击事件

本文发布于:2023-10-08 04:23:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471512.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   单击   类中   事件   NSView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!