问题
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:
- Create a NSViewController and set viewA as its "view" property.
- 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