Hi Nathan,
I discovered an even simpler approach that doesn't require any JavaScript. You can handle the VisibleChanged event only when opening the Window, and then control closing exclusively through a button click. This disables the Escape key behavior.
I've put together an example to demonstrate this approach. Additionally, I've marked the related item as a duplicate of the existing feature request for customizable keyboard shortcuts.
<TelerikWindow Modal="true"
Visible="@isModalVisible"
VisibleChanged="@VisibleChangedHandler"
CloseOnOverlayClick="true">
<WindowTitle>
Window Title
</WindowTitle>
<WindowContent>
I am modal, so the page content behind me is not accessible to the user.
</WindowContent>
<WindowActions>
<WindowAction Name="Close" OnClick="@CloseWindow" />
</WindowActions>
</TelerikWindow>
<TelerikButton OnClick="@( _ => isModalVisible = true )">Open the window</TelerikButton>
@code {
private bool isModalVisible { get; set; } = true;
private void VisibleChangedHandler(bool currVisible)
{
if (currVisible)
{
isModalVisible = currVisible;
}
}
private void CloseWindow()
{
isModalVisible = false;
}
}
Regards,
Hristian Stefanov
Progress Telerik
Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!
Hi Nathan,
I can confirm that disabling/enabling the Esc key action is easily achievable with a small JavaScript function. Here is an example with a disabled Esc key: REPL link.
Regards,
Hristian Stefanov
Progress Telerik
Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!