开发者

Getting a borderless window to receive mouseMoved events (Cocoa OSX)

I have a little popup window used for selecting images sorted by groups, and I would like to add a selection box around whatever image is being hovered over. I am trying to this by overriding the mouseMoved event for the window but it seems that a window that has a border-less style mask r开发者_StackOverfloweceives no mouseMoved events even if you have set setAcceptsMouseMoved events to YES. Is there anyway to make a borderless window receive this events?


You need to allow the window to become the key window. By default, borderless windows cannot become key. Subclass NSWindow and override -canBecomeKeyWindow:

- (BOOL)canBecomeKeyWindow
{
    return YES;
}

Aternatively, you can use an NSTrackingArea to do your mouse tracking, which may be easier/better anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜