Keyboard shortcuts for Back / Forward

5 posts, 1 answers
  1. Patrick
    Patrick avatar
    498 posts
    Member since:
    Aug 2012

    Posted 26 Jun Link to this post

    Hello,

    In the Windows Explorer, it is possible to use the Alt+Left keyboard shortcut for Back and the Alt+Right shortcut for Forward.

    Your file dialogs should do the same.

  2. Dinko
    Admin
    Dinko avatar
    1183 posts

    Posted 01 Jul Link to this post

    Hi Patrick,

    This behavior is already logged in our Feedback Portal, where you can track its progress and vote for its implementation.

    As a workaround: What you could try is to subscribe to the PreviewKeyDown event of the RadSaveFileDialog (or any other file dialog). In the event handler, you can check the current press key combination and execute the HistoryNavigationCommands.Back/Forward command. The tricky part here is that the HistoryNavigationPaneControl control (which holds the move back, move forward, etc. buttons) needs to be focused first. Check the following code snippet.

    private void ShowSaveFileDialog()
    {
        RadSaveFileDialog saveFileDialog = new RadSaveFileDialog();
        saveFileDialog.PreviewKeyDown += RadOpenFileDialog_PreviewKeyDown;
        saveFileDialog.ShowDialog();
        if (saveFileDialog.DialogResult == true)
        {
            Stream fileStream = saveFileDialog.OpenFile();
        }
    }
    
    private void RadOpenFileDialog_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        if (Keyboard.IsKeyDown(Key.LeftAlt) && e.SystemKey == Key.Left)
        {
            IInputElement focusedControl = Keyboard.FocusedElement;
            RadSaveFileDialog radOpenFileDialog = sender as RadSaveFileDialog;
            HistoryNavigationPaneControl historyNavigationPaneControl = radOpenFileDialog.ChildrenOfType<HistoryNavigationPaneControl>().FirstOrDefault();
            historyNavigationPaneControl.Focus();
            HistoryNavigationCommands.Back.Execute(null);
            focusedControl.Focus();
        }
        else if(Keyboard.IsKeyDown(Key.LeftAlt) && e.SystemKey == Key.Right)
        {
            IInputElement focusedControl = Keyboard.FocusedElement;
            RadSaveFileDialog radSaveFileDialog = sender as RadSaveFileDialog;
            HistoryNavigationPaneControl historyNavigationPaneControl = radSaveFileDialog.ChildrenOfType<HistoryNavigationPaneControl>().FirstOrDefault();
            historyNavigationPaneControl.Focus();
            HistoryNavigationCommands.Forward.Execute(null);
            focusedControl.Focus();
        }
    }

    Regards,
    Dinko
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. Patrick
    Patrick avatar
    498 posts
    Member since:
    Aug 2012

    Posted 01 Jul in reply to Dinko Link to this post

    Hi Dinko,

    I will try later and give you more information. The problem is that I need to implement this 3 times, as there are three dialogs.

  4. Answer
    Dinko
    Admin
    Dinko avatar
    1183 posts

    Posted 02 Jul Link to this post

    Hello Patrick,

    The RadOpenFolderDialog, RadOpenFileDialog and RadSaveFileDialog derives from DialogWindowBase. You can use that to make the custom code general for the three dialogs.

    private void RadOpenFileDialog_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        var dialog = sender as DialogWindowBase;
    
        if (Keyboard.IsKeyDown(Key.LeftAlt) && e.SystemKey == Key.Left)
        {
            IInputElement focusedControl = Keyboard.FocusedElement;
            HistoryNavigationPaneControl historyNavigationPaneControl = dialog.ChildrenOfType<HistoryNavigationPaneControl>().FirstOrDefault();
            historyNavigationPaneControl.Focus();
            HistoryNavigationCommands.Back.Execute(null);
            focusedControl.Focus();
        }
        else if (Keyboard.IsKeyDown(Key.LeftAlt) && e.SystemKey == Key.Right)
        {
            IInputElement focusedControl = Keyboard.FocusedElement;               
            HistoryNavigationPaneControl historyNavigationPaneControl = dialog.ChildrenOfType<HistoryNavigationPaneControl>().FirstOrDefault();
            historyNavigationPaneControl.Focus();
            HistoryNavigationCommands.Forward.Execute(null);
            focusedControl.Focus();
        }
    }

    Regards,
    Dinko
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  5. Patrick
    Patrick avatar
    498 posts
    Member since:
    Aug 2012

    Posted 07 Jul in reply to Dinko Link to this post

    Hi Dinko,

    It works, but I really think that it must work "out-of-the-box", without these kind of patches.

Back to Top