更改默认帮助键行为

更改默认帮助键行为

本文介绍了更改默认帮助键行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSWindowController的子类。在我的子类中,我有一个keyDown:方法。

I have a subclass of a NSWindowController. In my subclass, I have a keyDown: method.

当我按键盘上的帮助键,我的keyDown:方法不被调用,我想它因为我需要做一些自定义。

When I press the Help Key on the keyboard, my keyDown: method is not called and I would like it to be as I need to do something custom.

现在,当我按帮助键,光标变成一个问号。

Right now, when I press the help key, the cursor changes to a question mark.

任何人都知道如何覆盖帮助键的默认行为?

Anyone know how to override the default behavior of the help key?

推荐答案

已经能够找到是使用NSContextHelpModeDidActivateNotification检测何时进入此模式。

The best solution I've been able to find is to use the NSContextHelpModeDidActivateNotification to detect when this mode is entered.

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(helpContextModeActivated:)
                                             name:NSContextHelpModeDidActivateNotification
                                           object:nil];

调用选择器时,只需调用:

When the selector is called, simply call:

[NSHelpManager setContextHelpModeActive:NO];

取消激活模式并将光标向后移动。

to deactivate the mode and change the cursor back.

这篇关于更改默认帮助键行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 09:43