(NSWindowButton)NSWindow.standardWindowButton按钮未突出显示 [英] (NSWindowButton) NSWindow.standardWindowButton button not highlighting

查看:313
本文介绍了(NSWindowButton)NSWindow.standardWindowButton按钮未突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用以下按钮创建按钮时

When i use the following to create a button

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

我得到一个对鼠标悬停事件没有反应的按钮.我可以通过使用NSTrackingArea创建容器视图并手动触发highlight方法来增强此功能,但是它会产生单击状态.

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?

我一直试图避免对NSButton进行子类化,但是似乎我可能不得不这样做,而我只是处于拒绝状态.

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.

推荐答案

我一生都无法正常工作,因此我的解决方案是编写自己的自定义按钮.这对我来说很好,因为我的NSWindow已经是自定义的,因此不会出现样式冲突.

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

另一种可行的解决方案是将 https://github.com/indragiek/INAppStoreWindow 用作@ xhruso00提到过,但这似乎有些矫kill过正.

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

这篇关于(NSWindowButton)NSWindow.standardWindowButton按钮未突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆