简体   繁体   中英

NSTextField inside NSMenu — doesn't interact or look as expected

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:

在此输入图像描述

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.

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: 截图登录窗口

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM