(NSWindowButton) NSWindow.standardWindowButton button not highlighting

人走茶凉 提交于 2019-12-08 10:43:08

问题


When i use the following to create a button

NSWindow.standardWindowButton(NSWindowButton.ZoomButton, forStyleMask: 0)

I get a button that doesn't react to mouse hover events. I can augment this by creating a container view with a NSTrackingArea and manually triggering the highlight method but it produces a clicked state.

Is there a way to somehow force the button into the expected behavior state without the darkened background?

I have been trying to avoid subclassing NSButton, but it seems like i may have to, and I'm just in a state of denial.


回答1:


I could not get this working for the life of me so my solution was to write my own custom buttons. This works fine for me because my NSWindow is already custom so there wont be a clash of style.

https://gist.github.com/icodeforlove/a334884e59784b4c2567

Another viable solution is to use https://github.com/indragiek/INAppStoreWindow as @xhruso00 mentioned, but it seemed like overkill.



来源:https://stackoverflow.com/questions/32503282/nswindowbutton-nswindow-standardwindowbutton-button-not-highlighting

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