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

Keyboard shortcuts for Back / Forward

4 Answers 203 Views
FileDialogs
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Patrick asked on 26 Jun 2020, 12:51 PM

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.

4 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 01 Jul 2020, 11:36 AM

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.
0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 01 Jul 2020, 11:47 AM

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.

0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 02 Jul 2020, 01:30 PM

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.
0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 07 Jul 2020, 08:48 AM

Hi Dinko,

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

Tags
FileDialogs
Asked by
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or