Status Bar App Custom Interface

Discussion in 'Mac Programming' started by talguy, Jan 29, 2010.

  1. talguy macrumors member

    Joined:
    Jun 17, 2009
    #1
    I am trying to program an alarm clock for my mac that has an interface that is similar to gmail app called notify. I can set up my notify app to act as a menu but how can I turn this menu into a custom window. Not really good with objective-c pretty new out so any help would be most appreciated.

    Talguy
     
  2. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #2
    OS X does not have direct support for tear-off menus, as far as I know. You would have to create an NSPanel (which you could do in the nib file) and use something like an NSMatrix to replicate the menu items. If you want pop-up submenus, it will be a little more work than just that.
     
  3. talguy thread starter macrumors member

    Joined:
    Jun 17, 2009
    #3
    ok so I would also have to track where on the icon in the status bar is at so that I can draw an arrow pointing to the write icon
     
  4. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #4
    That part could be hard. I'm not sure how I'd do it without resorting to the accessibility API (which requires the user to have 'access for assistive devices' turned on in system prefs).
     
  5. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5
    You could try looking in [NSApp windows] for a NSStatusBarWindow and then playing with its frame. That is completely undocumented though...
     
  6. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #6
    Well, you can get the NSStatusItem's view. Would that not give its icon's location in screen coordinates?
     
  7. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #7
    I think that would only work if you actually set a custom view. If you only have a title, I think the view would be nil.

    An NSStatusItem has a private NSWindow ivar that you could get also, but you'd have to use the various Obj-C functions to ensure it actually exists and not crash if it doesn't...
     
  8. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #8
    You are correct. Even if the status item has an icon instead of a title, it still returns a nil view. You would have to write a custom view that draws and responds in the way you want. If it does not produce an actual menu, not really a huge problem, but if it does, you would have to use -popUpContextMenu:withEvent:forView: , which would not line up with the menu bar.
     
  9. talguy thread starter macrumors member

    Joined:
    Jun 17, 2009
    #9
    Thanks guys for all the suggestions. I take a closer look at the API and see what I can come up with
     

Share This Page