cocoa - 什么响应者捕获撤消操作?

标签 cocoa nswindowcontroller nsundomanager

我有一个处理撤消和重做的 View 。对于特定状态,我将第一响应者从 View 更改为 View 的窗口。现在在这种状态下,我希望窗口委托(delegate)中的 validateMenuItem: 方法检查撤消菜单项。

当我关闭窗口时,这会起作用。但是当窗口可见时,其他响应程序会处理撤消操作。

我的猜测是它是窗口 Controller ?但由于这是一个非基于文档的应用程序,我还没有手动实现。我必须创建自定义窗口 Controller 吗?如果是这样,最简单的方法是什么?

最佳答案

在这里找到答案:http://www.cocoabuilder.com/archive/cocoa/307917-validatemenuitem-not-called-for-undo-menu-item.html

Configuring the Undo menu item with action 'undo:' tells the frameworks that this is the undo menu item, so it becomes one element of a standard undo UI mechanism implemented in NSWindow. Under these circumstances, the menu item (and especially its validation) isn't yours to mess with.

If you want to take implement the entire mechanism yourself, then you should use a custom action such as 'myUndo:' for the Undo menu item. That means, as far as the frameworks know, you app doesn't have (standard) undo, and the action/validation should work in the normal way.

关于cocoa - 什么响应者捕获撤消操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15084321/

相关文章:

objective-c - Core Data UndoManager 发送奇怪的 NS

iphone - NSUndoManager 和 GLKit

objective-c - Cocoa中不按按钮触发回调

macos - 是否可以强制控制 NSWindowController 子类?

cocoa - 将 NSWindow 显示为工作表的正确方法

cocoa - 如何在基于 NSDocument 的 Cocoa 应用程序中使用 NSViewController

cocoa - 如何使 NSUndoManager 撤消/重做操作名称正常工作?

objective-c - 是什么导致 Mac OS X 上找不到合适的图像错误?

xcode - Cocoa NSTextField NSNumberFormatter 和委托(delegate)

objective-c - 如何将 NSdictionaries 的 NSarray 转换为 XML 文件?