Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7416139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:25:59+00:00 2026-05-29T07:25:59+00:00

Basically I have run-time loaded class that looks like this: [Plugin(Plugin name)] class PluginActions

  • 0

Basically I have run-time loaded class that looks like this:

[Plugin("Plugin name")]
class PluginActions
{
  [Action("Flip Normals")
  public void FlipNormals()
  {
    // code ....
  }

  [Action("Export .X object")
  public void ExportX()
  {
    // code ....
  }
}

This basically adds buttons to the form with the onClick eventhandlers set up.

Now I would like to specify HOTKEYs in the same style using attributes:

[Plugin("Plugin name")]
class PluginActions
{
  [Action("Flip Normals", Hotkey = "Ctrl+N")
  public void FlipNormals()
  {
    // code ....
  }

  [Action("Export .X object", Hotkey = "Ctrl+E")
  public void ExportX()
  {
    // code ....
  }
}

The question is, how to represent and capture the hotkeys? As strings? Is there perhaps a class for that?

void Form_KeyDown(object sender, KeyEventArgs e)
{
  // reflection magic ...

  foreach(var action in actionAttributes)
  {
    string action_hotkey = action.hotkey;

    /**** How to match KeyEventArgs against action_hotkey? ****/
  }
}

Is there a .net helper class for dealing with hotkeys?

Or do i have to roll out my own hotkey class of some kind?

What is the correct approach here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:26:00+00:00Added an answer on May 29, 2026 at 7:26 am

    There is the Keys enumeration in the System.Windows.Forms namespace. Then for hotkey Ctrl+A you can write something like this:

    public class Action : Attribute {
      public Keys HotKey {get;set;} 
    }
    
    
    [Action(HotKey = (Keys.Control | Keys.A))]
    public void MyMethod() {
      ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically have something like this: void Foo(Type ty) { var result = serializer.Deserialize<ty>(inputContent);
I have an interesting problem. I'd like to create a generic class that can
I have an object within an object. It looks like this. var myLib =
I'm trying to create a Textmate snippet, but have run into some difficulties. Basically,
I basically have three tables, posts, images and postimages (this simply contains the ids
I basically have 7 select statements that I need to have the results output
We have a big winforms C# application, that's basically a frontend for some databases
How to set crystal report's textbox value at run time. I have a textbox
I have a number of stored procs which I would like to all run
I have a Window shell that is basically: <Window> <ContentPresenter Content={Binding} /> </Window> Injected

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.