热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

为WindowsStore应用定制虚拟键盘-CustomizedvirtualkeyboardforWindowsStoreApp

SinceMicrosoftdoesntallowtoreplacethesystemsvirtualkeyboard,Ivedevelopedacustomvirt

Since Microsoft doesn't allow to replace the system's virtual keyboard, I've developed a custom virtual keyboard as a UserControl to be used inside my Windows Store App. My current problem is that the default virtual keyboard always pops up whenever a user taps a TextBox.

由于微软不允许替换系统的虚拟键盘,我开发了一个自定义虚拟键盘作为用户控件,可以在我的Windows Store应用程序中使用。

I've been searching for a solution to this problem since yesterday, but I couldn't solve it. My almost successful attempt was developing a TextBox with a transparent Canvas over it. When the user taps the Canvas, the focus is programatically transferred to the TextBox and my custom virtual keyboard is instantiated. However, if no physical keyboard is connected to the tablet, the system keyboard also pops up with this approach (over my custom keyboard).

从昨天起我一直在寻找解决这个问题的办法,但是我没有办法。我几乎成功的尝试是开发一个带有透明画布的文本框。当用户轻击画布时,焦点被程序化地转移到文本框中,我的自定义虚拟键盘被实例化。然而,如果没有物理键盘连接到平板电脑上,系统键盘也会弹出这种方式(通过我的自定义键盘)。

The main reason why I want to use a TextBox is because that way I can preserve and use the already implemented caret function, but it is not mandatory.

我想使用文本框的主要原因是,这样我可以保存和使用已经实现的插入符号函数,但它不是强制性的。

Any input will be helpful, thanks.

任何意见都可以,谢谢。

1 个解决方案

#1


0  

There are a couple of things you could do:

你可以做以下几件事:

There are events for when the keyboard shows up, check those and see if you can prevent it.

当键盘出现时,会出现一些事件,检查这些事件,看看是否可以阻止它。

You could implement a custom TextBox that suppresses OnPointerPressed event so that the TextBox is never focused. There are a couple of other things you'll need to do (such as prevent tabbing into it giving focus by setting IsTabStop=false.

您可以实现一个自定义文本框,该文本框抑制OnPointerPressed事件,这样文本框就不会集中。您还需要做一些其他的事情(例如通过设置IsTabStop=false来防止将焦点设置为it)。

You could implement a custom TextBox from the ground up (that looks and acts like a TextBox).

您可以从头开始实现一个自定义文本框(它的外观和功能类似于一个文本框)。

I think the second option is the easiest and most interesting option to try.

我认为第二个选择是最简单和最有趣的选择。

Edit: You could also give your TextBox a DependencyProperty that you set the current Page to via bindings. In the TextBox's OnGotFocus event, set the visual state to "CustomFocus" (or whatever you call it), then call Page.Focus();

编辑:您还可以给您的文本框一个DependencyProperty,您可以通过绑定将当前页面设置为DependencyProperty。在文本框的OnGotFocus事件中,将视觉状态设置为“CustomFocus”(或其他名称),然后调用Page.Focus();


推荐阅读
author-avatar
猪猪寂寞的王子_125
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有