Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Input Question

Input Question

Scheduled Pinned Locked Moved WPF
questioncsharpcsscomdocker
5 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Super Lloyd
    wrote on last edited by
    #1

    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!

    R 1 Reply Last reply
    0
    • S Super Lloyd

      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!

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #2

      In your TextBox.TextChanged event handler, before exiting the handler method, set e.Handled to true, 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

      S 1 Reply Last reply
      0
      • R realJSOP

        In your TextBox.TextChanged event handler, before exiting the handler method, set e.Handled to true, 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

        S Offline
        S Offline
        Super Lloyd
        wrote on last edited by
        #3

        Interesting... I gave it a go, and unfortunately the KeyDown happens before the TextInput event... I tried to override OnKeyDown in the TextBox, and even though I called base.OnKeyDown first, setting Handled = 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!

        R 1 Reply Last reply
        0
        • S Super Lloyd

          Interesting... I gave it a go, and unfortunately the KeyDown happens before the TextInput event... I tried to override OnKeyDown in the TextBox, and even though I called base.OnKeyDown first, setting Handled = 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!

          R Offline
          R Offline
          realJSOP
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • R realJSOP

            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

            S Offline
            S Offline
            Super Lloyd
            wrote on last edited by
            #5

            BTW 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!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups