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. Overriding the default keys used to navigate in RadioButtons [WPF] [VB]

Overriding the default keys used to navigate in RadioButtons [WPF] [VB]

Scheduled Pinned Locked Moved WPF
csharpwpfhelpquestion
4 Posts 3 Posters 0 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.
  • J Offline
    J Offline
    Jayme65
    wrote on last edited by
    #1

    Hi, In my application, the user has to navigate through RadioButton's group using the keyboard By default, the arrow keys are used to navigate and the space bar used to select the radio button. I would like the 'select' key to be another keyboard key! How should I please process to switch the key used for the button selection by the "A" key, for instance? Thank you for any kind help!

    S M 2 Replies Last reply
    0
    • J Jayme65

      Hi, In my application, the user has to navigate through RadioButton's group using the keyboard By default, the arrow keys are used to navigate and the space bar used to select the radio button. I would like the 'select' key to be another keyboard key! How should I please process to switch the key used for the button selection by the "A" key, for instance? Thank you for any kind help!

      S Offline
      S Offline
      SledgeHammer01
      wrote on last edited by
      #2

      You mean add a underscore (_) to the content? If you do "Radio Button #_1", the 1 will be underlined and a user can hit Alt+1 to select the radio button.

      J 1 Reply Last reply
      0
      • J Jayme65

        Hi, In my application, the user has to navigate through RadioButton's group using the keyboard By default, the arrow keys are used to navigate and the space bar used to select the radio button. I would like the 'select' key to be another keyboard key! How should I please process to switch the key used for the button selection by the "A" key, for instance? Thank you for any kind help!

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        A quick and dirty way would be to use your own RadioButton-derived class that responds to the key press you want, something like:

        public class MyRadioButton : RadioButton
        {
            protected override void OnKeyDown(KeyEventArgs e)
            {
                if (e.Key == Key.A)
                    OnClick();
                else
                    base.OnKeyDown(e);
            }
        }
        

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        1 Reply Last reply
        0
        • S SledgeHammer01

          You mean add a underscore (_) to the content? If you do "Radio Button #_1", the 1 will be underlined and a user can hit Alt+1 to select the radio button.

          J Offline
          J Offline
          Jayme65
          wrote on last edited by
          #4

          Thanks for your reply! No, that's not what I mean (sorry english isn't my mothertongue) I mean, being able to select the radio button which has the focus, with the key "A" instead of the default "SPACE" key!

          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