简体   繁体   English

Cocoa弹出菜单中是否可以使用层次结构?

[英]Are hierarchies possible inside a Cocoa popup menu?

I was just wondering if it is possible to create a drop down or popup menu with a hierarchy? 我只是想知道是否可以创建一个带有层次结构的下拉菜单或弹出菜单? The application I am currently working on tracks Assignments, Courses, and Subjects. 我目前正在处理的应用程序跟踪作业,课程和科目。 When the user creates an Assignment they will need to be able to select a Course that it belongs to from a drop down but I also wan't the drop down to be organized a little bit by having headers so the user can easily see what Subject that Course belongs to. 当用户创建作业时,他们将需要能够从下拉菜单中选择该课程所属的课程,但是我也不想通过具有标题来对下拉菜单进行一些组织,以便用户可以轻松地查看主题该课程所属。

Example: 例:

Select Course: [drop down below] 选择课程:[在下面下拉]
- Life - 生活
--Chores --Chores
--Eating - 吃
--Vacations --Vacations
- Math - 数学
--Algebra --Algebra
--Calculus - 结石

Etc... 等等...

Not the best example but the entries "Life" and "Math" would be bold and unselectable and all of the others would be regular menu items. 不是最好的例子,但条目“生活”和“数学”将是粗体和不可选择的,所有其他条目将是常规菜单项。 Does anyone have any suggestions? 有没有人有什么建议? Let me know if you need more information on what I am trying to do. 如果您需要有关我正在尝试做的更多信息,请告诉我。

Yes, if you build them manually in code or in Interface Builder. 是的,如果您在代码或Interface Builder中手动构建它们。 No, if you're using Bindings. 不,如果您正在使用Bindings。

NSPopUpButton takes an NSMenu full of NSMenuItems. NSPopUpButton带有一个充满NSMenuItems的NSMenu。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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