Sending key down events to TextBox
I am trying to send KeyDown/KeyUp Events to a TextBox when a User clicks a button from a separate NoesisView, something close to a virtual keyboard.
I have been using Unity and C#
I did a bunch of tests on the same NoesisView to see if that was the issue, but still no luck.
I have tried creating a new KeyEventArg and raising that event on the TextBox instance.
I have tried calling KeyDown on the TextBox View
The following works but I need to be able to send control keys to the TextBox
Is there a different way I should be doing this? or am I missing something.
I know I can use the Win32 API to send key events that way but I would like to use the framework if I can.
I have been using Unity and C#
I did a bunch of tests on the same NoesisView to see if that was the issue, but still no luck.
I have tried creating a new KeyEventArg and raising that event on the TextBox instance.
Code: Select all
((Button)FindName("TestButton")).Click += (sender, eventArgs) =>
{
var textBox = ((TextBox)FindName("TestInput"));
var kea = new KeyEventArgs(textBox, Noesis.Keyboard.KeyDownEvent, Key.A, KeyStates.Down | KeyStates.Toggled);
textBox.Focus();
textBox.RaiseEvent(kea);
};
Code: Select all
var textBox = ((TextBox)FindName("TestInput"));
textBox.Focus();
textBox.View.KeyDown(Key.A);
Code: Select all
((Button)FindName("TestButton")).Click += (sender, eventArgs) =>
{
var textBox = ((TextBox)FindName("TestInput"));
textBox.Focus();
textBox.View.Char('c');
};
I know I can use the Win32 API to send key events that way but I would like to use the framework if I can.
Re: Sending key down events to TextBox
Have you tried sending the events directly to the view? That's the way we are implementing Virtual Keyboards and IME in a few platforms.I am trying to send KeyDown/KeyUp Events to a TextBox when a User clicks a button from a separate NoesisView, something close to a virtual keyboard.
Re: Sending key down events to TextBox
How would I go about doing that? The View doesn't contain a RaiseEvent method. Is there another way I can send events directly to the View?
If I bind to the KeyDown event on the TextBox it does receive the event
But the actual text inside of the TextBox doesn't update
If I bind to the KeyDown event on the TextBox it does receive the event
Code: Select all
((TextBox)FindName("TestInput")).KeyDown += (sender, keyArgs) =>
{
Debug.Log(keyArgs.Key);
};
Re: Sending key down events to TextBox
The view provide several functions to inject events: KeyDown, KeyUp, Char, MouseMove...
Re: Sending key down events to TextBox
I have tried sending events directly to the view but still no luck. It is receiving the events but the text is not updating.
Re: Sending key down events to TextBox
Make sure that the TextBox has focus and also send the events in this order: KeyDow, Char, KeyUp for each keypress.
Re: Sending key down events to TextBox
Sending all 3 events ended up doing it. I miss read the documentation the first time. Thanks for your help!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 26 guests