NSTextView不会更新,除非我点击它,它不会重点。有任何想法吗? [英] NSTextView wont update unless I click on it, and it wont focus. Any ideas?
问题描述
我没有时间这一秒,放一些示例代码,(明天编辑我的问题,添加一些),但基本上会发生什么,我有一个窗口。它通常工作正常,但如果我使用
[myWindow setStyleMask:NSBorderlessWindowMask]
使它无边界,它包含的NSTextView将停止获得焦点,即使当你点击它:环永远不会出现,光标不会改变,滚动条将保持灰色。
当我使它无边界时发生的其他事情是它不会更新!我基本上有这个
[lyricsView setString:someString];
更新其中的字符串。控制台标记我没有错误,但字符串不会出现在文本视图中,除非我点击它。
如果我删除的行设置
styleMask
无边框。有任何想法吗?建议?注释?干杯?
谢谢!
Kevin解决方案从NSWindow的文档:
如果窗口有标题栏或调整大小栏,NSWindow实现返回YES。
此行
- (BOOL)canBecomeKeyWindow
{
return YES;
}
I dont have time right this second to put some sample code, (Ill edit my question tomorrow and add some) but basically what happens is that I have a Window. It works fine usually, but if I use
[myWindow setStyleMask:NSBorderlessWindowMask]
to make it borderless, the NSTextView it contains will stop gaining focus even when you click on it: the ring will never appear, the cursor wont change and the scroll bar will remain gray.
Something else that happens when I make it borderless is that it wont update! I basically have this
[lyricsView setString:someString];
to update the string inside it. The Console marks me no errors, but the string wont appear in the Text View unless I click on it.
All of this stops happening if I remove the line setting the
styleMask
to Borderless. Any ideas? Suggestions? Comments? Cheers?Thank You! Kevin
解决方案From the documentation of NSWindow:
The NSWindow implementation returns YES if the window has a title bar or a resize bar, or NO otherwise.
So subclass your window and add this line
-(BOOL)canBecomeKeyWindow { return YES; }
这篇关于NSTextView不会更新,除非我点击它,它不会重点。有任何想法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!