如何禁用单击父菜单项而不禁用它? [英] How to disable clicking parent menu item without disabling it?

查看:124
本文介绍了如何禁用单击父菜单项而不禁用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用一些带有子菜单的父级顶部菜单链接,以便当我单击根目录顶部时,在导航并单击其子菜单以进行特定操作之前,什么都不会发生.

例如,在可可中,如果我有菜单文件->;最近-> "...最近的文件列表...." ,我可以按最近".我想防止按最近".我可以吗?

谢谢!

I want to disable some of parent top menu links with sub-menus, so that when I click at the root top nothing should happen until I navigate and click to its sub menus for specific action.

For example, In Cocoa, if I have menu File -> Recent -> "...Recent files list...." , I can press "Recent". I want to prevent pressing "Recent". Can I do it?

Thanks!

推荐答案

问题及其背后的原理很难理解,但是禁用菜单项而不禁用它"我只能以一种方式理解:正式未禁用,但是没有处理单击它的事件,或者它是处理程序,但是处理程序在特定条件下不执行任何操作.如果是这样,则全部取决于处理程序的代码,该处理程序应检测到这种情况并且不执行任何操作.符合逻辑,不是吗?

但是,整个想法看起来像是不良的UI设计的征兆.无论您如何实现这种行为,用户都不会在此状态下获得视觉反馈,也不会看到对某些项目的单击是无用的,因为它是禁用但未禁用"的.目前尚不清楚该项目的正常禁用状态有什么问题.

—SA
The question and the rationale behind it is hard to understand, but "disable menu item without disabling it" I could understand in only one way: it is formally not disabled, but the event of click on it is not handled, or it is handler, but the handler does nothing on certain condition. If so, it all depends on the code of the handler which should detect this situation and do nothing. Logical, isn''t it?

However, the whole idea looks like a sign of a bad UI design. No matter how you implement such behavior, the user would not get a visual feedback on this state and would not see that the click on some item is useless because it is "disabled but not disabled". It is not clear what''s wrong with normal disabled state of the item.

—SA


我可能对自己的解释不够好.

没关系.解决方案是对具有子菜单"的项目调用[menuItem SetAction:0].
这样,您将无法选择该项目.
I probably not explained myself good enough.

Never mind. The solution is call [menuItem SetAction : 0] for the item having Sub Menus.
In this way you will not be able to select this item.


这篇关于如何禁用单击父菜单项而不禁用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆