2

I've been working on a new feature for Mac support in Qt. Basically, it's about adding a NSStatusItem::title() support. Since Qt is a C++ framework, I am working in scope of ObjC-binding (corresponding method is declared in C++ header and defined in .mm source file).

void QCocoaSystemTrayIcon::updateTitle(const QString &title)
{
    NSString *nstitle = title.toNSString();
    [trayItem setTitle: nstitle];
}

Note: in the code above, toNSString() creates & releases a proper NSString* in place.

Interesting, if you replace actual setting line with

[[trayItem view] setToolTip: nsstring];

tool tip, in fact, is being changed. It proves that trayItem and nsstring are proper objects.

I am running IIRC latest OS X Yosemite 10.10.1

2 Answers2

2

Almost all NSStatusItem methods are deprecated in Yosemite because of the new vibrancy features. Nice description here, NSStatusItem change image for dark tint

Community
  • 1
  • 1
Daniel Farrell
  • 9,316
  • 8
  • 39
  • 62
  • I am aware that we might keep it as it is for a while to keep legacy. On other hand it doesn't explain why the method takes no effect... – Ian P Badtrousers Jan 27 '15 at 18:47
  • When compiling for Yosemite SDK those methods literally do nothing because they are not used by the OS. If you target pre-Yosemite you should have no problems (legacy support as you mentioned). – Daniel Farrell Jan 27 '15 at 18:51
  • I was looking into some docs on how to work with NSStatusBarButton, but IIRC there is even no official API reference, what the? – Ian P Badtrousers Jan 27 '15 at 19:06
2

The fact that [trayItem view] returns a valid object suggests that you or Qt is setting a custom view.

Once you set a custom view on a status item, setting the title has no effect. (This was true even before these methods were deprecated).

A standard status item (no set custom view) can have its image and title set and have that be forwarded onto the implicitly created button. This was made more explicit/obvious in 10.10 in that those status item properties were deprecated, and you set the button's properties directly.

Taylor
  • 3,183
  • 17
  • 18