问题
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