ui::TextField是一个cocostudio的输入框,点击输入框,可以键盘输入文字。 我们希望点击其他地方的时候,键盘输入无效,于是我看到了ui::TextField 里的 setDetachWithIME
然后我就调用了这个方法:
TextField* m_input = dynamic_cast<TextField*>(layout_root->getChildByName("edit_name"));
m_inpute->setDetachWithIME(true);运行后发现,这方法无效,键盘输入依然进行。
网上搜寻了很久,最后用了下面的方法解决的此问题:
<pre name="code" class="cpp">TextField* m_input = dynamic_cast<TextField*>(layout_root->getChildByName("edit_name"));
static_cast<CCTextFieldTTF*>(m_input->getVirtualRenderer())->detachWithIME();
本文介绍了一种在CocosStudio中使用ui::TextField时,通过特殊方法禁止点击其他区域时键盘输入的方法。通常setDetachWithIME不起作用,文章提供了一个替代方案,通过CCTextFieldTTF实现键盘输入的关闭。
5148

被折叠的 条评论
为什么被折叠?



