Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What is the height of the frame of the view? Maybe your view is taller than the menubar and you are drawing outside of it. The current menubar is 22 pixels, but you should ask the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusBar_Class/Reference/Reference.html#//apple_ref/occ/clm/NSStatusBar/systemStatusBar" rel="nofollow noreferrer">systemStatusBar</a> for it's <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusBar_Class/Reference/Reference.html#//apple_ref/occ/instm/NSStatusBar/thickness" rel="nofollow noreferrer">thickness</a>, just in case it ever changes.</p> <p>Try drawing a frame around your view to see if you are getting anything.</p> <pre><code>[[NSColor blueColor] set]; NSBezierPath *path = [NSBezierPath bezierPathWithRect:self.bounds]; [path setLineWidth:4.0f]; [path stroke]; </code></pre> <p>If you get just an 'L' shape (the bottom left corner) of blue then the view is too large. If you get a rectangle but still no text then you may not be drawing the text inside the view, look at the coordinates you are drawing the text at (and review <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Coordinates/Coordinates.html#//apple_ref/doc/uid/TP40002978-CH10-SW1" rel="nofollow noreferrer">View Geometry</a>). Putting the view in a window may have worked because it is larger.</p> <p>For an example of using text in a status menu view take a look at Matt Gemmell's <a href="http://mattgemmell.com/2008/03/04/using-maattachedwindow-with-an-nsstatusitem" rel="nofollow noreferrer">NSStatusItemTest</a> project.</p> <p>EDIT:</p> <p>Sorry, somehow I missed where you said you created the view in IB. I did a quick test and I can see the white box you mentioned. </p> <p>The docs for <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusItem_Class/Reference/Reference.html#//apple_ref/occ/cl/NSStatusItem" rel="nofollow noreferrer">NSStatusItem</a>'s <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusItem_Class/Reference/Reference.html#//apple_ref/occ/instm/NSStatusItem/setView:" rel="nofollow noreferrer">setView:</a> states</p> <blockquote> <p>The custom view is responsible for drawing itself and providing its own behaviors, such as processing mouse clicks and sending action messages.</p> </blockquote> <p>And status item views go into a special (apple private) window called NSStatusBarWindow that may have different internal behavior than normal windows and certainly seems to not support views from IB.</p> <p>So yes, I think you need to create a custom NSView subclass and do your own drawing in drawrect:.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload