Input Question
-
I have a... an unusual control (its a container for visuals), to which I just added a TextBox (user can click somewhere and add some text). This control also listen to Key down event and on 1,2,3,4 it does something. Now the problem is, it also happens when the user is typing in the TextBox, which is less than ideal, to say the least. I can see that the KeyEventArgs.OriginalSource is different from KeyEventArgs.Source (my container), could I use that reliably perhaps? Any other tips?
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
I have a... an unusual control (its a container for visuals), to which I just added a TextBox (user can click somewhere and add some text). This control also listen to Key down event and on 1,2,3,4 it does something. Now the problem is, it also happens when the user is typing in the TextBox, which is less than ideal, to say the least. I can see that the KeyEventArgs.OriginalSource is different from KeyEventArgs.Source (my container), could I use that reliably perhaps? Any other tips?
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
In your
TextBox.TextChanged
event handler, before exiting the handler method, sete.Handled
totrue
, and see if that works.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
In your
TextBox.TextChanged
event handler, before exiting the handler method, sete.Handled
totrue
, and see if that works.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Interesting... I gave it a go, and unfortunately the
KeyDown
happens before theTextInput
event... I tried to overrideOnKeyDown
in theTextBox
, and even though I calledbase.OnKeyDown
first, settingHandled = true
prevented text input entirely... :O No matter, my test of only handling key input in global container if it was the original source worked! :) Thanks for interesting suggestion though!A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
Interesting... I gave it a go, and unfortunately the
KeyDown
happens before theTextInput
event... I tried to overrideOnKeyDown
in theTextBox
, and even though I calledbase.OnKeyDown
first, settingHandled = true
prevented text input entirely... :O No matter, my test of only handling key input in global container if it was the original source worked! :) Thanks for interesting suggestion though!A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
My next suggestion was to look at one of the preview events, and to make sure the source of the input was correct. :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
My next suggestion was to look at one of the preview events, and to make sure the source of the input was correct. :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013BTW the inline text editor is progressing nicely.. now I "just" need to add the text to the map... :) [Text-Input — ImgBB](https://ibb.co/0qkJbwL)
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!