Answered by:
How to use CoreWindow::CharacterReceived

Question
-
What's the different from CoreWindow::KeyDown
How can I get characters input by IME ?
Thanks!
C++ DX11
Saturday, June 2, 2012 6:37 AM
Answers
-
The IME communicates with the application via TSF, so if you need to receive input from the IME (or other advanced input such as spelling checks, type-ahead prediction, etc.) you will need to implement the Text Services Framework (TSF) interfaces. We do not have any documentation or guidelines or samples on how exactly to do this beyond the TSF documentation linked above.
If at all possible, I strongly recommend using Xaml text controls rather than trying to create your own.
--Rob
- Marked as answer by Raptor K Tuesday, July 10, 2012 3:27 AM
Monday, July 9, 2012 10:53 PMModerator
All replies
-
CharacterReceived delivers the interpreted character. This should give you the characters from the IME.
Keyup and Keydown deliver the I interpreted key used to generate the character. They cannot differentiate between characters that require multiple keys to generate.
--Rob
Saturday, June 2, 2012 3:49 PMModerator -
Then how to get the char from IME in DirectX app without XAML?
Is it possible to activate IME without system's touch keyboard?
Thanks.
C++ DX11
Sunday, June 3, 2012 2:23 AM -
CoreWindow::CharacterReceived is not Xaml: you can use that in your DirectX app to receive character input.
I don't think you can activate the IME without the touch keyboard. Even if you implemented the Text Service Framework (TSF) interfaces yourself to mimic the keyboard, the same accessibility cues which the IME responds to would activate the soft keyboard and the IMEs interact with the input pane.
You can find more information about TSF at: http://msdn.microsoft.com/en-us/library/windows/apps/ms629032.aspx
You can find more information about writing IMEs (and from the other side, what they depend on) at: http://msdn.microsoft.com/en-us/library/windows/apps/hh967425.aspx--Rob
Tuesday, June 5, 2012 1:04 AMModerator -
Even I activate the system's touch keyboard with UIA, it seems CoreWindow::CharacterReceived can only receive char from system's touch keyboard under English language . But cannot receive from multi-key input IME, like Chinese ( even English mode in Chinese IME ), only [space] [return] [backspace] key can be received.
C++ DX11
Tuesday, June 5, 2012 1:59 AM -
The language shouldn't matter here. I've asked one of our Chinese speaking colleagues to take a look at how the Chinese IME works with this.
Thursday, June 7, 2012 5:49 AMModerator -
As I know, we can't change ime mode when non-text input elements are focused. I'm not sure if it's related to your problem. Could you please provide the steps to reproduce your problem. I need to test it in-house first.
Best Regards,
Han XiaThursday, June 7, 2012 9:49 AMModerator -
Activate touch keyboard with UIA method, http://msdn.microsoft.com/en-us/library/windows/apps/hh465404.aspx
change IME with the keyboard's right-bottom button.
Or could you please give me a right way (a simple sample) to get IME output char in non-XAML (CoreWindow) App .
- Edited by Raptor K Thursday, June 7, 2012 2:28 PM
Thursday, June 7, 2012 2:05 PM -
You can follow this article to get IME output char in CoreWindow app. I tested it in a D3D application and it works fine.
http://msdn.microsoft.com/en-us/library/windows/apps/hh465033.aspx#view_codecpp
Best Regards,
Han XiaMonday, June 11, 2012 9:46 AMModerator -
I tried this sample, it need some modifications to be compiled under 2012RC.
So, is it mean that CoreWindow::CharacterReceived can ONLY receive interpreted KeyCode for a key on keyboard. Not chars interpreted by IME.
C++ DX11
Tuesday, June 12, 2012 1:09 PM -
I found CoreWindow::CharacterReceived can receive asian chars from Handwriting mode of IME but the Compose mode only gets key name ... (with the touch pad/kbd on simulator)
What's the different ?
- Edited by Raptor K Sunday, July 1, 2012 9:57 AM
Sunday, July 1, 2012 9:55 AM -
The IME communicates with the application via TSF, so if you need to receive input from the IME (or other advanced input such as spelling checks, type-ahead prediction, etc.) you will need to implement the Text Services Framework (TSF) interfaces. We do not have any documentation or guidelines or samples on how exactly to do this beyond the TSF documentation linked above.
If at all possible, I strongly recommend using Xaml text controls rather than trying to create your own.
--Rob
- Marked as answer by Raptor K Tuesday, July 10, 2012 3:27 AM
Monday, July 9, 2012 10:53 PMModerator -
Answering to the thread question
in MainPage.xaml
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <TextBlock Name="Text1" Text="Hallo" FontSize="72" /> </Grid>
then in MainPage.xaml.cpp
void MainPage::OnCharacterReceived(_In_ Windows::UI::Core::CoreWindow^ sender, _In_ Windows::UI::Core::CharacterReceivedEventArgs^ args){ wchar_t iChar[2]; swprintf(iChar, sizeof(iChar)/sizeof(wchar_t), L"%c", args->KeyCode); Text1 -> Text = ref new Platform::String(iChar);}MainPage::MainPage(){ InitializeComponent(); CoreWindow ^coreWindow = Window::Current->CoreWindow; coreWindow->CharacterReceived += ref new TypedEventHandler<CoreWindow^, CharacterReceivedEventArgs^>(this, &MainPage::OnCharacterReceived);}
don't forget to add OnCharacterReceivder to private in MainPage.xaml.h
But this is not will be work in tapped (On Screen) keyboard, Charles Petzold warn it in his last book.
P.S.
Tested in VS 2012 EE RC on Windows 8 Release Preview
(8400).
P.S.S.
See more at http://msdn.microsoft.com/en-us/library/windows/apps/hh465089.aspx
- Edited by TheViceMan Monday, August 6, 2012 12:56 PM
Monday, August 6, 2012 12:53 PM