0
votes

I'm attempting to create a log-in window inside an NSMenu (attached to the an NSStatusItem in the menu bar).

I have blank NSMenuItems in the menu. I then set the views of the menu items to NSTextFields.

It ends up looking like this:

enter image description here

The textfields also interact strangely. Clicking on them only gives them focus (so you can enter text) about 30% of the time.

So, I'm wondering:

-How do do I make these look better? How do I control the padding, etc?

-What's with the clicking behavior I described above? Typing only works 30% of the time.

-Are there any other apps that use such a statusbar item as a field? I'd like to take a look.

1
Don't do this please. It's very bad UI design. Menus are not meant to take the keyboard's focus.Jonathan Grynspan
Is your complaint with the UI of logging-in in the menubar, or with using an NSMenu? Spotlight, for example, is designed for taking keyboard focus...ck_
That doesn't mean you should attempt to do the same thing. Spotlight can be called upon frequently and has no other system-wide user interface; the user is unlikely to log in to his/her account repeatedly.Jonathan Grynspan
It's an app that exists entirely as a menu-bar item (no windows, no dock icon).ck_
In this case, you really should present a modal alert for the (usually) one-time task of login. Store the user's credentials in the keychain, and refer back to them on subsequent sessions.Jonathan Grynspan

1 Answers

2
votes

To answer your actual question instead of discussing the UI design...

Alternative:
Consider using the MAAttachedWindow project from Matt Gemmel:
Download the use an MAAttachedWindow with an NSStatusItem example.

Link:
http://mattgemmell.com/source/index.html

Quickly created example: Screenshot Login Window

Used controls:
- NSTextField (Focus:None DrawsBackground:No TextColor:White)
- NSButton (Bezel:Recessed)
- NSLabel (TextColor:White)