Function key to call a menu option

Hello, 

How do I place a function key to call a menu option?
And how does the show in menu?
Thanks
Alberto Ferraz
  •  Hi

    I've got the function keys appear on the menu options.

    Now how do you use them?

    Best Regards

    Alberto Ferraz

    ,

  • I would highly recommend that for questions like this, how to use a .NET class or WPF functionality that you Google your question to other sources than this forum. The reason is that .NET is a Microsoft technology and there are many examples of how to use the various classes on other web sites and within the MSDN documentation.

    For example, the link here explains how to handle a Menu control in WPF and provides examples in C#. These examples normally translate directly into COBOL but if you require help with the translation you can post your questions here.

    Thanks

  • Verified Answer

    Hi,

    I have researched a lot by Google but still could not find the solution and so resorted here to the forum.

    I have also researched the link you sent me but I found the solution.

    I will continue to look to see if I have better luck.

    Thanks

    Best regards

    Alberto Ferraz

  • Ferraz, I created a quick sample in WinForms and by simply specifying the short-cut keys in the Collection they were enabled. There was no special code necessary to enable them. I first tried the sample with a mouse click and then I pressed "Ctrl 1" which was the short-cut and it worked.

    How did you specify your short-cut keys?

  • Hi Rick,

    I want de Function Key (F1/F2/F3/...) like i have in picture. 

    Interest is to use the function keys to directly call the menu options.

    Thanks

    Alberto Ferraz

  • Alberto, my sample is using WinForms and the properties for the menus enable this. If you're not using WinForms there may be some differences.

  • Hi,

    I am using WPF so I do not know if your solution will be compatible.

    Anyway if I want to send can check and test.

    Thanks

    Alberto Ferraz

  • I have done some research on this and have found in the link that I provided to you a section on using Commands in WPF and binding them to controls like menu items and buttons, etc.

    In particular the one that I found useful was to define all of your command as type RoutedUICommand within a static class and then bind your menu items to these commands within XAML.

    By attaching the CanExecute and Executed events to each command you can have it automatically invoke a specified method whenever the command is executed. Commands can be executed by selecting the control such as a menu item or by pressing a key which you have defined as an InputGesture for the command.

    There was some syntax in the C# example for RoutedUICommands that involved initializing a collection directly within the constructor of the field that was not directly supported in the current version of Visual COBOL so I devised a workaround of creating a property for each of the commands.

    I have attached an example to this post. The example defines the commands used in a static class and then references them both as menu items and as buttons. You could also use the same commands in a context menu.

    Let me know if you have any questions:

    Thanks.

    WPFFunctionKeys.zip
  • I Chris.

    I've been to see the example that sent me, and I confess I have not been able to understand well.

    Tomorrow I will review it again to see if I can understand.

    Then I give the feed-back.

    Thanks for your time.

    Best Regards

    Alberto Ferraz

  • Verified Answer

    Hello,

    Sometimes we complicate what can be simplified.

    I solved the problem by creating the "Menu_KeyDown" event and i detect the function keys and depending on each call a menu option.

    Thanks.