NSButton默认按钮带蓝色外观 [英] NSButton default button with blueish look

查看:216
本文介绍了NSButton默认按钮带蓝色外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有1个或多个按钮的对话框,并且希望能够以编程方式将最右边的一个设置为默认对话框,以便当用户按下Enter或Return键时,它应该像用户单击它一样进行响应。 / p>

我正在使用 [btn setKeyEquivalent:@ \r] ,它可以正常工作,但是我希望按钮具有不出现的偏蓝外观。我该怎么办?

解决方案

我缺少正确设置按钮边框样式的功能,这就是为什么它看起来不正确的原因正确地。我现在将按钮设置为:

  [btn setBezelStyle:NSRoundedBezelStyle]; 

然后进行以下任何操作以设置默认按钮:

  [myWindow setDefaultButtonCell:[btn单元格]]; 

  [btn setKeyEquivalent:@ \r] 


I have a dialog with 1 or more buttons and want to be able to programmatically set the rightmost one be the default one, so that when the user presses the Enter or Return key it should respond as if the user clicked it.

I'm using [btn setKeyEquivalent:@"\r"] and that makes it work fine but I want the button to have the blueish look which isn't happening. What do I need to do?

解决方案

I was missing to set the button bezel style properly and that's why it didn't look properly. I'm now setting the button as this:

[btn setBezelStyle:NSRoundedBezelStyle];

Then any of these work to set the default button:

[myWindow setDefaultButtonCell:[btn cell]]; 

or

[btn setKeyEquivalent:@"\r"] 

这篇关于NSButton默认按钮带蓝色外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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