开发者

NSWindow title bar color only works for active window?

I've got a Qt app running under MacOS/X, and I'd like to set the color of the app's windows. Based on various Stackoverflow answers I came up with this little Objective-C function which more or less works:

extern "C" void changeTitleBarColor(WId winId, double red, double green, double blue, double alpha, bool makeTextWhite)
{
   if (winId == 0) return;

   NSView* view = (NSView*)winId;
   NSWindow* window = [view window];
   if (alpha > 0.0) window.backgroundColor = [NSColor colorWithRed:red green:green blue:blue alpha:alpha];
               else window.backgroundColor = NULL;  // set title bar back to its default appearance
}

However, there's one problem -- the only time the window displays its custom title-bar color is when it's the active window (i.e. after I click on it). Any other windows in m开发者_开发技巧y app that aren't currently the active window revert their title bar back to the system-default appearance until I click on them again.

Is there any way to get MacOS/X to retain my custom color when the window isn't the currently active window?

(see attached screenshot -- desired behavior is that all three windows' title bars would be green, not just the one I most recently clicked on)

NSWindow title bar color only works for active window?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜