I noticed the other day that one of my web pages was looking ugly. The buttons on the page looked totally different, based on whether they contained one line of text or two.
After some digging, I've learned that the typical button uses NSRoundedBezelStyle
, but it has a fixed height. So, if the text is going to wrap, Firefox (and Chrome and Safari) will change the button to use NSShadowlessSquareBezelStyle
which can have a variable height. I'd like to petition the maintainers of these browsers to change this and am researching the best alternative.
After finding the already-filed bug and doing some reading, I suggested that maybe they could use NSTexturedSquareBezelStyle
instead. It turns out that in Mavericks it looks almost exactly the same as an NSRoundedBezelStyle
button. Same in Yosemite, except that it has no border. Changing setBordered
has no effect.
So my question, on behalf of browser developers everywhere: is it possible to draw an NSTexturedSquareBezelStyle
button with a border? Or, is there another way around this that all the browser vendors have missed?
Rewritten Answer
I'm not seeing an NSTexturedSquareBezelStyle
button showing up borderless in Yosemite:
This is a stock button dragged from the palette in Interface Builder. I encourage you to post your code since it's likely you're generating your button in code. Here's my own code for generating the same button:
NSButton * anotherButton = [[NSButton alloc] initWithFrame:NSMakeRect(10.0, 10.0, 100.0, 100.0)];
anotherButton.bezelStyle = NSTexturedSquareBezelStyle;
anotherButton.title = @"Line 1\nLine 2";
Proof:
If you're seeing different results under Yosemite, you'll need to post your code. At a guess, you might be initializing your button with -init
instead of -initWithFrame:
, which can cause all kinds of drawing issues since NSButton
is an NSView
and therefore its designated initializer is -initWithFrame:
. Just a guess though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With