开发者

Borderless NSButton turns gray when clicked

I am making a little application with three NSButtons with an image set. These buttons have开发者_开发百科 no border nor background. However, when I click a button it turns into a gray rectangle.

How can I fix this? Thanks.


Make your button type as NSMomentaryChangeButton.

[myBtn setButtonType:NSMomentaryChangeButton];

If you use NSMomentaryPushInButton then you may get gray rectangle over the button when click.


You should be able to adjust this by changing the state mask. To do so, check out the highlightsBy: and showsStateBy: properties of NSButtonCell - they are for setting the press effect and displaying the effect respectively. The applicable constants for these methods are in the NSCell reference page.


If you are using an NSBox, make sure your button inside of NSBox in the hierarchy. Then use 'momentary push in' as your button type. The button will dim when clicked but there will be no border.

When I used NSBox with NSButton on the same hierarchy level, I would see the border when clicked.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜