NSCursor is changed when there is an overlay NSView over others

all:


I have added two NSViews into the window. View A is on the top, and View B is under the A. On the View B, there are textfields, buttons, and so on. The view A is overly view, there is nothing but on imageView. When I move mouse on the View A, the mouse cursor will change to hand cursor if I mouse to the position where buttons stay at(View B). It seems that the mouse cursor passthrough from View A to B, the mouse cursor is changed by View B.


Can we prevent the passthrough from A to B?


Thanks very much.

Yes, events are sent to next view until handled.


You could implement trackingRectangles in ViewA and a cursorUpdate func, to trap the message.

override func cursorUpdate(with event: NSEvent) {

//

}


See for details:

h ttps://developer.apple.com/library/content/documentation/Cocoa/Conceptual/EventOverview/EventObjectsTypes/EventObjectsTypes.html#//apple_ref/doc/uid/10000060i-CH4-SW4


for defining trackingRect :

h ttps://stackoverflow.com/questions/32447739/changing-nscursor-for-nsview-above-an-nstextview

That doesn't work. AppKit still seems to handle any mouse movement over a NSTextField even if there's another view on top.
NSCursor is changed when there is an overlay NSView over others
 
 
Q