2016-06-08 51 views
2

我有一个警告/警告图标,当用户输入的内容可能不完全正确时出现。当用户将鼠标悬停在图标上时,可能会出现错误的解释会显示为工具提示。如何在按钮点击时调出工具提示

我希望工具提示也出现在用户点击图标上的,所以我把它变成了NSButton,但我找不到任何方法来强制显示工具提示!

帮助感谢!

+0

你有没有想出解决办法? –

+0

恐怕不是。 –

回答

1

您可以使用上下文敏感的帮助,以立即显示工具提示:

NSHelpManager *helpManager = [NSHelpManager sharedHelpManager]; 
[helpManager setContextHelp:[[[NSAttributedString alloc] initWithString:[view toolTip]] autorelease] forObject:view]; 
[helpManager showContextHelpForObject:view locationHint:[NSEvent mouseLocation]]; 
[helpManager removeContextHelpForObject:view]; 
相关问题