Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

talguy

macrumors member
Original poster
Jun 17, 2009
30
0
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
 
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

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.
 
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
 
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).
 
You could try looking in [NSApp windows] for a NSStatusBarWindow and then playing with its frame. That is completely undocumented though...
 
Well, you can get the NSStatusItem's view. Would that not give its icon's location in screen coordinates?
 
Well, you can get the NSStatusItem's view. Would that not give its icon's location in screen coordinates?

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...
 
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.

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.
 
Thanks guys for all the suggestions. I take a closer look at the API and see what I can come up with
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.