This is a migrated thread and some comments may be shown as answers.

RadShortcut Problem

3 Answers 118 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Mohsen
Top achievements
Rank 1
Mohsen asked on 12 Jul 2014, 08:20 AM
Hi,
I am using Telerik 2014 Q1 SP1.
this is my code:

public Form1()
 {
     InitializeComponent();
 
     RadMenuItem rtsmNew = new RadMenuItem("New");
     rtsmNew.Click += rtsmNew_Click;
    
     RadShortcut rs=new  RadShortcut(Keys.None, Keys.F2);
     rtsmNew.Shortcuts.Add(rs);
     rtsmNew.HintText = rs.GetDisplayText();
 
   }
 
public void rtsmNew_Click(object sender, EventArgs e)
 {
     new Form2().ShowDialog();
 }
when i am in Form1 and hit F2, it opens Form2 in dialoge mode. everything is ok so far but the problem is even when Form2 is open and i hit F2 it will again open Form2 and thats repeat.
but i think the shortcuts are suppose to work when the form is active!

also if i use raddock, no matter which tabbed document is active, the shortcuts for first form in tabbed documents  will works!!!!

So obviously i want shortcuts to perform whenever my form is active.

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 16 Jul 2014, 01:34 PM
Hi Mohasen,

Thank you for writing.

I tried to reproduce the described problem, but to no avail. No matter if I show Form2 using the ShowDialog or the Show method, the shortcut was working only when Form1 was focused. You can find my sample project attached below. Please, inspect it and let me know if there is anything that I am missing. Can you also confirm that you are using version 2014.2 617 of UI for WinForms?

Looking forward to your response.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Mohsen
Top achievements
Rank 1
answered on 20 Jul 2014, 12:07 PM
hi, thanks for your post,
the only difference is that i am using radmenu's in RadGridView.
           
           radContextMenu1.Items.Add(rtsmNew1);

            RadContextMenuManager m = new RadContextMenuManager();
            m.SetRadContextMenu(radGridView1, radContextMenu1);


by the way my telerik version is 14.1.403.0
0
George
Telerik team
answered on 23 Jul 2014, 12:06 PM
Hello Mohsen,

Thank you for replying.

Indeed the fact that the item was in a context menu was the key in this case. I can confirm that this is an issue with RadShortcut. You can find the issue logged on the following url: UI for Winforms Feedback Portal - FIX. RadShortcut - If added to RadMenuItem which is in a context menu the click event of the item is always fired, even if the form is not active. As a workaround you can simply check whether the menu is visible. I would also suggest you to close the menu prior opening the new form:
private void rtsmNew_Click(object sender, EventArgs e)
{
    RadMenuItem item = sender as RadMenuItem;
    if (item.ElementTree.Control.Visible)
    {
        (item.ElementTree.Control as RadContextMenuDropDown).ClosePopup(RadPopupCloseReason.CloseCalled);
        new Form().Show();
    }
}

I have updated your Telerik Points for reporting this.

Let me know, should you have further questions.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Menu
Asked by
Mohsen
Top achievements
Rank 1
Answers by
George
Telerik team
Mohsen
Top achievements
Rank 1
Share this question
or