tags:

views:

124

answers:

2

How can I add text on top of a NSLevelIndicator? [the NSLevelIndicator is in my statusbar, if that matters]

+2  A: 

The best way to add text to your NSLevelIndicator user interface is by adding a separate Label NSTextField. The NSLevelIndicator control does not have a title or other text associated with it.

From within Interface Builder, just grab a Label and drag it to your window above or beside the NSLevelIndicator.

Jess Bowers
Since this is within a status item, the questioner probably means z-on-top-of, not y-on-top-of. That is, text in the foreground, level indicator in the background. That can be problematic: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/WorkingWithAViewHierarchy.html#//apple_ref/doc/uid/TP40002978-CH4-SW16
Peter Hosey
+2  A: 

Contrary to the correct answer to your previous question, if you want to use an NSLevelIndicator as a background and draw text on top of it, you're better off creating a custom view that owns and uses an NSLevelIndicator*Cell* for the background drawing.

You might also consider drawing the background yourself; e.g., fill with your choice of green/yellow/red, and then draw a white gradient on top of it. This is more appropriate if you're not really indicating a level with your level indicator.

Also, don't forget to test your application with Sim Daltonism, to make sure that the text is still readable to color-blind users.

Peter Hosey