选择文本输入时强制显示键盘
在这种情况下,我有一个输入文本字段,我正在执行部分自动完成(与 Stack Overflow 上的标签输入字段完全相同......因为这基本上就是这样)。
当用户打字时,我建议他们可能输入的内容;然后,用户单击其中一个建议,它会替换一些字段内容,并将光标放在插入发生的位置之后。
所有这些都有效,但是插入后软件键盘不再显示。您可以在桌面 Stack Overflow 站点上复制此内容。
SO 上的代码并不完全相同,但症状是相同的。
这是将文本插入文本字段后调用的实际代码。
$(field).focus()[0].setSelectionRange(newCaretPos, newCaretPos);
(是的,setSelectionRange 是非标准的;但它适用于我此刻关心的所有移动设备,所以暂时忽略它)
在 android、iphone 等上,这工作得很好(键盘“闪烁”,但我愿意忍受它。
所以,问题基本上可以归结为:如何强制屏幕键盘出现在 Windows Phone 7(Mango 更新)上?
The scenario, I have an input text field I'm doing partial auto-complete on (exactly like the Tags input field on Stack Overflow... because that's what is, basically).
As a user is typing, I suggest things they may typing; the user then clicks one the suggestions, it replaces a bit of the fields content, and places the cursor after where the insert occurred.
All this works, but after the insertion the software keyboard isn't shown anymore. You can replicate this on the desktop Stack Overflow site.
The code on SO isn't exactly the same, though the symptom is.
Here's the actual code called after the text is inserted into the text field.
$(field).focus()[0].setSelectionRange(newCaretPos, newCaretPos);
(Yes yes, setSelectionRange is non-standard; but it works on all the mobile devices I care about just this moment, so ignore it for now)
On android, iphone, etc. this works fine (the keyboard "flickers" but I'm willing to live with it.
So, the question basically boils down to: How can I force the onscreen keyboard to appear on Windows Phone 7 (Mango update)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,无法保证强制 SIP 在 WP7 中显示。 :(
Sorry, there is no guaranteed way to force the SIP to display in WP7. :(
通常将焦点设置在文本框上会强制使用键盘。您是否尝试过仅设置焦点? (即不设置选择范围)
Normally setting the focus on the textbox would force the keyboard. Have you tried just setting the focus? (i.e. not setting the selection range)