问题描述
在Mac OS X上,对单词进行3指点击,会弹出一个带有该单词定义的窗口。
On Mac OS X, doing a 3-finger tap on a word pops up a window with a definition of the word.
在Xcode中,对符号进行3指点击显示其文档,非常像是已经被alt +单击。
This idiom is also used in Xcode, where doing a 3-finger tap over a symbol shows its documentation, much like if it had been alt+clicked.
我想做类似的事情并且当我的应用程序的用户在 NSTextView
中对某些令牌进行3指点击时显示定义。但是,我找不到如何检测用3个手指完成敲击。
I would like to do something similar to that and display definitions when users of my application do a 3-finger tap on certain tokens in a NSTextView
. However, I can't find how to detect that a tap has been done with 3 fingers. Could someone help me with that?
编辑如果这提醒任何人,三个事件(通过覆盖 NSApplication sendEvent:]
)在你做这种敲击时触发:
EDIT If this reminds anything to anyone, three events (caught by overriding [NSApplication sendEvent:]
) are triggered when you do this kind of tap:
NSEvent: type=SysDefined loc=(270.918,250.488) time=417954.6 flags=0x100 win=0x0 winNum=28293 ctxt=0x0 subtype=6 data1=1818981744 data2=1818981744
NSEvent: type=SysDefined loc=(270.918,250.488) time=417954.6 flags=0x100 win=0x0 winNum=28293 ctxt=0x0 subtype=9 data1=1818981744 data2=1818981744
NSEvent: type=Kitdefined loc=(0,263) time=417954.8 flags=0x100 win=0x0 winNum=28306 ctxt=0x0 subtype=4 data1=1135411200 data2=1132691456
推荐答案
Reacting on a triple tap in a NSTextView
can most easily be done by overriding quickLookWithEvent:
.
-(void)quickLookWithEvent:(NSEvent *)event
{
NSLog(@"Look at me! %@", event);
}
它还教会了你可以三次点击任何东西来调用Quick Look 。
It also taught me that you can triple tap anything to invoke Quick Look on it.
这篇关于如何覆盖NSTextView中的3手指点击行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!