How do I make an NSPathControl look like other dropdown boxes?

末鹿安然 提交于 2019-12-11 05:53:31

问题


I'm wrestling with NSPathControl. Specifically, I have a dialog (generated by a NIB) which asks the user for a title and a path. The path is supposed to be a local path on the user's hard drive. So, in Xcode 4, I dragged in an NSPathControl. In the Attributes inspector, I set its style to "Pop Up".

This pretty much works like I expect. If I click it, I get a menu with a few common paths or paths related to the current selection, and a "Choose..." option which opens up a dialog box and allows a path selection.

The problem is, it doesn't look like a Cocoa dropdown, because there's no border or button stuff at all. How can I make this look more like an NSPopUpButton, which is presumably what someone would expect.

Alternatively, I'm new to Cocoa and willing to be told I'm going about this the wrong way. If I'm going about it the wrong way, what's a better way to go about having the user select a path?

Here's an example of what I'm trying to do:

See the path dropdown? I would have expected it to look like one of these...

...but, that said, I'm trying to write a well-behaved Cocoa app, so what I really want is, "What's the right way to do this?" Thanks in advance.


回答1:


The way I've done this before is by recreating the control myself using a highly customized NSPopUpButton. I don't know of a better way. You should ask for one.




回答2:


I tried with something and here is the result. Download Running Model.

this can be a hack or tweak, what to say I dont know

This is NSPathControl+NSButton Giving you a look-feel of NSPopUp.



来源:https://stackoverflow.com/questions/7478252/how-do-i-make-an-nspathcontrol-look-like-other-dropdown-boxes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!