0

Put a Push Button on a custom NSView that has a background color, and in Light Mode, the button background remains white (both buttons are Push style with the default Tint) — but switch to dark mode and now the button takes on the background behind it.

Button background color light mode vs. dark mode

Note the button (top right in image) color on a View that does not have a background color set looks as expected.

Is there a way to make a Push Button behave the same way in Dark Mode and not take on the color of the NSView behind it?

Ken
  • 1,691
  • 5
  • 22
  • 38
  • What kind of "why" is this? Are you asking for why Apple did it this way? That would fall into the realm of speculation. – matt Oct 02 '19 at 16:43
  • That's a really good point, @matt — I'm more surprised by the behavior than anything and am looking to see if anyone has helpful info. – Ken Oct 02 '19 at 18:07
  • I'm surprised too, but Stack Overflow is not a venue for expressing surprise (or disapproval) about Cocoa and its behavior. – matt Oct 02 '19 at 18:15
  • Changed question @matt so it's a little less philosophical; thanks for your help with that. – Ken Oct 02 '19 at 18:25
  • Excellent, well done! Thanks for doing that. – matt Oct 02 '19 at 18:43
  • OK so now I'd say this is a duplicate of e.g. https://stackoverflow.com/questions/1017468/change-background-color-of-nsbutton. Changing the background color of an NSButton is not easy and has been well studied. :) – matt Oct 02 '19 at 18:48
  • I disagree, @matt — I'm not trying to change the button to a specific color, just trying to get the button to behave the same way in Dark Mode that it does in Light Mode. – Ken Oct 02 '19 at 22:40
  • Yes, but the way you would do that is presumably to change its background color. – matt Oct 02 '19 at 22:55
  • Is "behave the same way" white buttons? In Dark Mode both buttons are translucent and the gray button also takes on the color behind it. – Willeke Oct 03 '19 at 09:51

0 Answers0