FloatingWindow and Key Events

4 posts, 1 answers
  1. Steve
    Steve avatar
    11 posts
    Member since:
    Jun 2013

    Posted 01 Jul Link to this post

    I would like to be able to capture key events from a floating window.

    Nothing I've tried seems to fire the OnKeyDown events associated with either the RadForm, FloatingParent or DockWindow.  I wired them up a variety of ways including in DockStateChanged.  Are the key events even intended to work for a floating window?

    I'm using version 2017.2.613.40 of UI for WinForms.

    I'm creating a new DockWindow with my user control which appears in the tabbed region in the middle of the RadDock.  I then float that window by dragging the tab.  Because the user may have several open floating windows, I want the global shortcut keys to function such as Ctrl+S to save everything even if they are in a floating window.  

    Events DO fire from my control that is hosted in the floating window.  However, when one drags the floating window and the focus is on the window, key events don't fire.  

    What's the proper way to wire of a floating window to capture key events?

     

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 03 Jul Link to this post

    Hi Steve,

    You should set the KeyPreview property when the floating window is created:
    private void RadDock1_FloatingWindowCreated(object sender, Telerik.WinControls.UI.Docking.FloatingWindowEventArgs e)
    {
        e.Window.KeyPreview = true;
       
        e.Window.KeyDown += Window_KeyDown;
    }
     
    private void Window_KeyDown(object sender, KeyEventArgs e)
    {
       
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Steve
    Steve avatar
    11 posts
    Member since:
    Jun 2013

    Posted 03 Jul in reply to Dimitar Link to this post

    OK.  It's working now.  I was missing 

       e.Window.KeyPreview = true;

    Thanks.

  4. Steve
    Steve avatar
    11 posts
    Member since:
    Jun 2013

    Posted 03 Jul in reply to Dimitar Link to this post

    OK.  It's working now.  I was missing

    e.Window.KeyPreview = true;

    Thanks.

Back to Top