在 Windows Phone 8.1 Direct3D 应用程序中调出软键盘 [英] Bringing up the soft keyboard in a Windows Phone 8.1 Direct3D app

查看:22
本文介绍了在 Windows Phone 8.1 Direct3D 应用程序中调出软键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 C++/CX 和 DirectX 11 将游戏移植到 Windows Phone 8.1.我需要调出软键盘来输入一些文本.

I'm porting a game to Windows Phone 8.1 using C++/CX with DirectX 11. I need to bring up the soft keyboard for some text input.

在 Windows phone 8 下,我在这里使用了微软提供的代码:

Under Windows phone 8, I used the code provided by Microsoft here:

如何处理键盘在 Windows Phone 8 的 Direct3D 应用程序中输入

这运行良好,但此代码在 Windows Phone 8.1 中均无效,而且我找不到任何更新的信息.我怎样才能在 8.1 中做到这一点?我需要显示/隐藏键盘并监听键盘输入.弹出一个带有文本输入元素的对话框也是可以接受的.

This worked well but none of this code is valid in Windows Phone 8.1 and I've been unable to find any updated information. How can I do this in 8.1? I need to show/hide the keyboard and listen for keyboard inputs. Popping up a dialog box with a text input element would also be acceptable.

推荐答案

简单的方法:

  • (on phone, but not desktop) call InputPane.TryShow and TryHide to explicitly open the input pane out of context from an actual control. You can catch the input in the CoreWindow.CharacterReceived event.

(在任一上)通过 Xaml DirectX 互操作.这个具有易于使用的优点,因为 Xaml 控件已经实现全文所需的可访问性和 IME 接口支持.它的缺点是在 DX 场景之外,所以它可能需要一些小心才能很好地放置它.

(on either) use a Xaml TextBox on top of your DirectX surface via Xaml DirectX Interop. This has the advantage of being easy as the Xaml controls already implement the accessibility and IME interfaces needed for full text support. It has the disadvantage of being external to the DX scene so it can require some care to place it nicely.

我通常尝试做Xaml 中的完整交互式表单,而不是尝试合并单个 TextBox 进入一个场景.像您提到的那样将控件放在 Xaml 弹出窗口中应该可以很好地工作.

I generally try to do the full interactive form in Xaml rather than trying to merge a single TextBox into a scene. Putting the controls in a Xaml popup like you mention should work nicely.

艰难的方式:

  • 通过提供 UI 自动化文本模式文本服务框架 (TSF) 接口.在内部,这就是 Xaml 文本控件所做的,以便它们在系统中显示为文本.当用户将焦点设置到文本控件(支持文本模式)时,键盘将自动打开.
  • Implement your own fully functional control by providing the UI Automation text patterns and Text Service Framework (TSF) interfaces. Internally this is what the Xaml text controls do so that they appear to the system as text. When the user sets the focus to a text control (that supports the text patterns) the keyboard will automatically open.

这篇关于在 Windows Phone 8.1 Direct3D 应用程序中调出软键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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