NSView loses mouseMoved/mouseDragged if dragged in from subview

拜拜、爱过 提交于 2020-04-11 04:23:07

问题


A = the parent NSView; B = the child NSView;

B has a small NSTrackingArea; B is a small subview of A;

A correctly receives mouseMoved and mouseDragged events if moved,clicked, dragged in a empty area.

If i click in B and drag the mouse outside of its bounds into A, A does not receive any mouseMoved or mouseDragged events.

Can someone point me to what i could do to get the superview A to react to this drag?


回答1:


I've observed this and I was able to solve it by doing as follows:

  1. Create a NSViewController and set viewA as its "view" property.
  2. In my case, I implemented mouseDragged in the view-controller but you can try on the view and see what results you get. mouseEntered and mouseExited were implemented in the view subclass.

Tip: Make sure you're updating the tracking area bounds as needed. Hope this helps.



来源:https://stackoverflow.com/questions/16589363/nsview-loses-mousemoved-mousedragged-if-dragged-in-from-subview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!