Completed
Last Updated: 16 May 2019 06:13 by ADMIN
Tomislav
Created on: 27 Mar 2019 14:23
Category: UI for WinForms
Type: Bug Report
0
RadMenuItem, Accelerator Key is not underlined

Accelerator Key is working but not underlined (underline is enabled in windows 10 and visible in other applications).


Telerik.WinControls.UI, Version=2019.1.117.40

3 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 04 Apr 2019 12:12
Hello, Tomislav,    

The provided code snippet was very helpful. Indeed, when the RadMenuItem is placed inside a RadDropDownMenu, the specific letter is not underlined. 

I can suggest you two solutions:

1. Keep using the RadDropDownMenu, but handle its DropDownOpened event where you can iterate the items and set the ShowKeyboardCues property to true for the text element inside each menu item: 

public RadForm1()
{
    InitializeComponent();
 
    this.radMenuItem1.Text = "&File";
 
    this.radMenuItem1.Click += radMenuItem1_Click;
    this.MouseClick += RadForm1_MouseClick;
}
 
private void RadForm1_MouseClick(object sender, MouseEventArgs e)
{
    RadMenuItem menuItem = new RadMenuItem();
    menuItem.Text = "Acc key is &X";
    menuItem.Font = new System.Drawing.Font("Segoe UI", 9f, FontStyle.Regular);
    menuItem.Click += (s, args) => MessageBox.Show("Click");
 
    if ((e.Button & MouseButtons.Left) != 0)
    {
        RadContextMenu menu = new RadContextMenu();
        menu.Items.Add(menuItem);
        menu.Show(Cursor.Position);
    }
    else
    {
        RadDropDownMenu menu = new RadDropDownMenu();
        menu.DropDownOpened += menu_DropDownOpened;
        menu.Items.Add(menuItem);
        menu.Show(Cursor.Position);
    }
}
 
private void menu_DropDownOpened(object sender, EventArgs e)
{
    RadDropDownMenu menu = sender as  RadDropDownMenu;
    foreach (RadMenuItem item in menu.Items)
    {
        item.Layout.Text.ShowKeyboardCues = true;
    }
}

2. Use the RadContextMenuDropDown which is a derivative of the RadDropDownMenu and enables the keyboard cues automatically.

Feel free to use this approach which suits your requirement best.

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tomislav
Posted on: 02 Apr 2019 12:04

Hello Dess,

 

I didn't realize it is sometimes shown as i have been using the RadDropDownMenu container.

In the example left and right mouse click have the same RadMenuItem, and on both the accelerator key is working,

but it is not underlined when the container is the RadDropDownMenu.


private void RadForm1_MouseClick(object sender, MouseEventArgs e)
{
var menuItem = new RadMenuItem();
menuItem.Text = "Acc key is &X";
menuItem.Click += (s, args) => MessageBox.Show("Click");


if((e.Button & MouseButtons.Left) != 0)
{
var menu = new RadContextMenu();
menu.Items.Add(menuItem);
menu.Show(Cursor.Position);
}
else
{
var menu = new RadDropDownMenu();
menu.Items.Add(menuItem);
menu.Show(Cursor.Position);
}
}

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 02 Apr 2019 11:36
Hello, Tomislav,   

Accelerators are a fast way to associate a keyboard shortcut to a menu item, for instance the File menu item to the shortcut Alt+F. In order to do that precede the F letter in the File string with the & symbol e.g. &File. The F letter is underscored when visualized and the Alt+F, Alt+f shortcuts are set automatically. These shortcuts work for the whole application no matter whether the menu has the current focus or not.

Following the provided information, the underlined letter is displayed when the Alt key is pressed. Please refer to the attached gif file illustrating the behavior on my end with the specified version. I have attached my sample project. 

Could you please specify the exact steps how to reproduce the problem?

I am looking forward to your reply.

 Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.