Close RadCalculatorPicker on Enter (or alternative key input)

1 Answer 68 Views
Calculator
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Renier Pretorius asked on 22 Jun 2022, 08:58 AM

Hi,

The  RadCalculatorPicker is a great option to provide spreadsheet-like input for the user. You can open the calculator by hitting the down-arrow key, but once opened the only way to close is to click on the button again. Typically the user will be entering on the keyboard, typing in the formula rather than clicking it in, making this pretty cumbersome.

Is there a way to automatically close the popup when hitting enter, an event I can intercept?

Regards

Renier

1 Answer, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 24 Jun 2022, 02:44 PM

Hello Renier,

The RadCalculatorPicker element can be closed by pressing the Escape key. Additional information about this and other keys can be found in the Keyboard Support article of the control's documentation.

Regarding the closure of the control when the Enter key is hit, you could subscribe to the PreviewKeyDown event of RadCalculatorPicker. In it, cast the sender parameter to the type of RadCalculatorPicker, and if the e.Key property is Key.Enter, and set the IsDropDownOpen property to false.

The following snippet shows this suggestion's implementation:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        //RadCalculatorPicker instance
        this.radCalculatorPicker.PreviewKeyDown += RadCalculatorPicker_PreviewKeyDown;
    }

    private void RadCalculatorPicker_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        var calculatorPicker = (RadCalculatorPicker)sender;

        if (e.Key == Key.Enter)
        {
            calculatorPicker.IsDropDownOpen = false;
        }
    }
}

Could you give this suggestion a try?

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Calculator
Asked by
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or