RadShortcut Problem

4 posts, 0 answers
  1. Mohsen
    Mohsen avatar
    2 posts
    Member since:
    Jul 2014

    Posted 12 Jul 2014 Link to this post

    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.
  2. George
    Admin
    George avatar
    500 posts

    Posted 16 Jul 2014 Link to this post

    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mohsen
    Mohsen avatar
    2 posts
    Member since:
    Jul 2014

    Posted 20 Jul 2014 in reply to George Link to this post

    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
  5. George
    Admin
    George avatar
    500 posts

    Posted 23 Jul 2014 Link to this post

    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.
     
Back to Top