I am running into an issue with what I believe is the default behaviour of the TelerikWindow, namely capturing @onkeydown - events and closing the window when the user presses escape.
Is there any way to disable this default behaviour of the dialog / overwrite its onkeydown event handler?
---
ADMIN EDIT
Include the ability to :
If you have any preferences how to expose this functionality please leave a comment. Any feedback on how to handle this on a Mac for the Ctrl and CMD keys is welcome (e.g. should the shortcut for the Ctrl key handle the CMD key for the Mac automatically).
In the meantime you could use the following snippet as a workaround to disable the Esc key:
@result
<TelerikButton OnClick="@ToggleWindow">Toggle the Window</TelerikButton>
<TelerikWindow Visible="@isVisible" VisibleChanged="@VisibleChangedHandler">
<WindowTitle>
<strong>The Title</strong>
</WindowTitle>
<WindowContent>
This is my window <strong>popup</strong> content.
</WindowContent>
<WindowActions>
<WindowAction Name="MyCustomClose" Icon="@IconName.Close" OnClick="@MyCustomCloseHandler" />
</WindowActions>
</TelerikWindow>
@code {
bool isVisible { get; set; }
string result { get; set; }
void VisibleChangedHandler(bool currVisible)
{
// if you don't do this, the window won't close because of the user action
// so if you don't update the view-model here, the window will not close when Esc is pressed
//isVisible = currVisible;
result = $"the window is now visible: {isVisible}";
Console.WriteLine($"Closing because of Esc key");
}
void MyCustomCloseHandler()
{
//will fire on click only
isVisible = false;
//since the built-in window UI didn't invoke this change, the event will not fire
}
public void ToggleWindow()
{
isVisible = !isVisible;
result = $"the window is now visible: {isVisible}";
}
}
---