我有一个用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子类中的鼠标单击事件
发布评论