的Windows Phone 8.1的Swype键盘事件捕获 [英] windows phone 8.1 swype keyboard event capture

查看:260
本文介绍了的Windows Phone 8.1的Swype键盘事件捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新[16月2014]:这个问题在技术上是不正确。阅读的答案,以获得更多的细节。

我试图达到我的文本框前捕获文本。我发现了以下事实:

I was trying to capture text before reaching to my text box. and I discovered the following facts:


  • 的KeyDown 的KeyUp 事件会告诉你什么 virtualKey 按下
    不是字符!

  • KeyDown, KeyUp event will tell you what virtualKey was pressed not the character !!

CoreWindow.CharacterReceived 将捕捉到的字符,但这个结果
事件不是针对文本框,它会告诉你字符结果
则达到了到TextBox后

CoreWindow.CharacterReceived will capture the character but this
event is not specific to TextBox and it will tell you the character
after it reached to the textBox.

现在我的问题是:

任何一个可以告诉我怎么可以捕获在Windows Phone 8.1的Swype键盘的情况下?

Can any one tell me how can I capture the event of the Swype Keyboard on windows phone 8.1?

的通知即:

1 - 我试图捕捉它TextBox.Paste但它失败:(

1- I tried to capture it in TextBox.Paste but it fails :(

2 - 本次活动 textBox.textChanged()是不是我期待的BEC该事件火键盘完成,此事件(框TextChanged)将火灾发生后后 KEYDOWN KEYUP CharacterReceived 无论文本是如何输入。

2- The event textBox.textChanged() is not what I am looking for bec that event fire after the keyboard is done and this event (textChanged) will fire after keyDown, keyUp, CharacterReceived regardless of how the text was input.

推荐答案

好吧,我一直在这个问题上几天,广泛的测试,理解并得出以下结论上来:

OK! I have been in this issue for days and extensively tested it to understand and came up with the following conclusions:

1,从键盘输入由名为页面的事件处理( CharacterRecieved )的事件被触发,捕获由页上,然后发送到文本框,并会导致框TextChanged 在触发事件。

1- the input from keyboard is handled by the event of the page named (CharacterRecieved). the event is fired and captured by the Page then sent to the TextBox and will result in the firing of TextChanged event.

2 - 如果你来的WinRT和Windows Phone与WinForms的心态,你一定会有困惑我别无选择,需要一定的时间来弄明白[除非你读这个答案这将使它短。

2- If you come to winRT and windows phone with the winForms mentality you will surely have the confusion i had, and will take some time to figure it out [unless you read this answer which will make it shorter].

3,不要指望[我错误地预期]所输入的字符的事件将触发在文本框中。它会激活页面(CoreWindow),然后改变文本框的文本值,所以你必须赶上在页面级别的事件,而不是在控制水平。

3- Don't expect [ as I falsely expected ] that the event of the character entered will fire in the TextBox. It will fire on the page (CoreWindow) then changes the text value of the textBox, so you have to catch the event on the page level, not on the control level.

按键盘上输入一个字母,并使用了Swype键盘输入一个字之间。4-区别:

4- Difference between entering one letter by keyboard and entering one word using swype keyboard:

**


  • 由键盘在手机上输入一个字母案例,按照以下顺序
    将mos晶体管逻辑可能发生:

  • in Case of One letter entered by the keyboard on the phone, the following sequence will mostl likely happen:

**

假设 textBox.Text =99;

现在我会按数字7:

1 的KeyDown 活动将火:在这里你可以捕捉到 virtualKey ,但你将无法知道字符,因此按A字母,你可以'知道它是'A'的资本或'a'小。
textBox.Text =99; 结果
2 - CharacterRecieved 消防; textBox.Text =997; 结果
3 的KeyUp 事件火; textBox.Text =997; 结果
4- 框TextChanged 火; textBox.Text =997;

1- KeyDown event will fire: here you may capture the virtualKey but you won't be able to know the character, so pressing 'a' letter you can't know is it 'A' capital or 'a' small. still textBox.Text = "99";
2- CharacterRecieved Fire; textBox.Text = "997";
3- KeyUp event fire; textBox.Text = "997";
4- textChanged fire.; textBox.Text = "997";


  • 而在的情况下, Swype输入键盘:

  • while in case of swype-keyboard:

假设 textBox.Text =99;
,我想输入文字你好;

suppose textBox.Text = "99"; and I want to enter the text "hello";

的Swype将单词前加上白色的空间,这将是你好

swype will add white space before the word so it will be " hello"

和事件序列是如下:

1-对字符串中的每个字符你好,将一个环触发事件 CharacterRecieved textBox.Text 值将是 textBox.Text =99 在第一次迭代;然后从第二次迭代的 textBox.Text =99你好;在每次迭代
你可以捕捉到键码[字符] 这是在这种情况下(32,110,101,108,108,111)。注意到,现在的 textBox.Text 值被改变但尚未显示的画面!

1- a loop for each character in the string " hello" will fire the event CharacterRecieved and the textBox.Text value will be textBox.Text= "99 " in the first iteration; then from the second iteration the textBox.Text = "99 hello"; in each iteration you can capture the key code [char] which is in this case (32, 110, 101, 108,108, 111). notice that by now the textBox.Text value is changed however not yet shown on the screen !!

2 - 上在框TextChanged 事件将触发两次(奇怪!我觉得一个是白色的空间,第二个单词你好),同时,由现在 textBox.Text =99你好,但仍然没有显示屏幕,直到两次迭代在TextChanged事件的结束上。

2- The textChanged event will fire twice (weird !! i think one for the white space and the second for the word "hello"), Also, by now the textBox.Text = "99 hello" but still not yet shown on the screen till the end of the two iterations over the textChanged event.

通过这一点,我们来注意这是在Swype输入没有的keydown KEYUP 可言!

With this we come to notice the difference between swype and normal keyboard key events which is that in swype there is no keyDown keyUp events at all !!

现在事件(Swype输入/非Swype的),你可以计划你的验证和应用程序的行为如你所愿。前提是您知道它比传统的窗口系统输入完全不同。

Now if you know the scenarios with each method of keyboard input ( swype/non-swype) you can plan your validation and application behaviour as you wish. provided that you know it is totally different than the legacy windows system input.

我希望这会帮助别人那里救他/她几个小时的困惑和痛苦的:)

I hope this will help someone there and save him/her many hours of confusion and agony :)

这篇关于的Windows Phone 8.1的Swype键盘事件捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆