From 0e1b203d1c1fd67ca5f4851cbd8b5a5cd10c388f Mon Sep 17 00:00:00 2001 From: KrithikaGanesan Date: Fri, 24 Oct 2025 15:58:08 +0530 Subject: [PATCH 1/2] 985360: Updated ReadMe file of this repository --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1944ca9..2795999 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,14 @@ -# How-to-modify-or-disable-shortcuts-of-EditControl -This repository contains the sample that how to modify or disable shortcuts of EditControl. +# How to Modify or Disable Shortcuts of EditControl +This repository provides a detailed example of how to modify or disable keyboard shortcuts in the Syncfusion EditControl for WPF applications. The EditControl is a versatile text editor component that supports syntax highlighting, code editing, and customizable features. In certain scenarios, developers may want to override or disable default shortcuts such as Undo (Ctrl+Z) and Redo (Ctrl+Y) to implement custom logic or restrict user actions. -The EditControl Undo and Redo functionality can be modify or disable by using the IsUndoEnabled and IsRedoEnabled property of Editcontrol. +## Key Features Demonstrated in This Sample + +- Disable Undo and Redo functionality using the built-in properties IsUndoEnabled and IsRedoEnabled. +- Intercept keyboard shortcuts using the PreviewKeyDown event. +- Apply conditional logic to enable or disable specific shortcuts dynamically. + +## Disable Undo and Redo Using Properties +The simplest way to disable these features is by setting the properties: ```C# public Window1() @@ -10,7 +17,8 @@ Edit1.PreviewKeyDown += Edit1_PreviewKeyDown; } ``` -You can also use our PreviewKeyDown event to modify this Undo and Redo features using the following code: +## Modify Shortcuts Using PreviewKeyDown Event +You can also customize shortcut behavior by handling the PreviewKeyDown event: ```C# private void Edit1_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) @@ -23,3 +31,4 @@ Edit1.IsUndoEnabled = true; } ``` +This approach gives you full control over how shortcuts behave, allowing you to implement advanced scenarios such as enabling Undo only for certain operations or disabling it entirely in read-only modes. \ No newline at end of file From a52bf21eea11491a4bf701d60e629e2d2e14a96a Mon Sep 17 00:00:00 2001 From: Manivannan-E <92844213+Manivannan-E@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:48:48 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 76 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 2795999..0617bc9 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,64 @@ -# How to Modify or Disable Shortcuts of EditControl -This repository provides a detailed example of how to modify or disable keyboard shortcuts in the Syncfusion EditControl for WPF applications. The EditControl is a versatile text editor component that supports syntax highlighting, code editing, and customizable features. In certain scenarios, developers may want to override or disable default shortcuts such as Undo (Ctrl+Z) and Redo (Ctrl+Y) to implement custom logic or restrict user actions. +# How to Modify or Disable Shortcuts in WPF EditControl +This example demonstrates how to disable or modify keyboard shortcuts in the Syncfusion WPF EditControl. By default, EditControl supports common shortcuts like Undo (Ctrl+Z) and Redo (Ctrl+Y). In some scenarios, you may want to override or disable these shortcuts to implement custom logic or restrict user actions. -## Key Features Demonstrated in This Sample +## Why This Is Useful +- **Custom Behavior**: Implement your own shortcut logic. +- **Restrict Actions**: Disable Undo/Redo in read-only or controlled environments. +- **Dynamic Control**: Enable shortcuts only under specific conditions. -- Disable Undo and Redo functionality using the built-in properties IsUndoEnabled and IsRedoEnabled. -- Intercept keyboard shortcuts using the PreviewKeyDown event. -- Apply conditional logic to enable or disable specific shortcuts dynamically. +## Key Approaches +1. Disable Undo and Redo using properties: + - IsUndoEnabled = false + - IsRedoEnabled = false +2. Intercept keyboard shortcuts using PreviewKeyDown: + - Apply conditional logic to enable or disable shortcuts dynamically. -## Disable Undo and Redo Using Properties -The simplest way to disable these features is by setting the properties: +## Code Example +**XAML** +```XAML + +``` +**C#** ```C# -public Window1() + +public partial class Window1 : Window { -Edit1.PreviewKeyDown += Edit1_PreviewKeyDown; -} -``` + public Window1() + { + SfSkinManager.SetTheme(this, new Theme("Office2019Colorful")); + InitializeComponent(); -## Modify Shortcuts Using PreviewKeyDown Event -You can also customize shortcut behavior by handling the PreviewKeyDown event: + Edit1.DocumentSource = @"../../Content.txt"; -```C# -private void Edit1_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) -{ -if(e.Key == Key.Z && (e.KeyboardDevice.Modifiers & ModifierKeys.Control) != 0) -{ -//Undo feature enable by checking the keys. -Edit1.IsUndoEnabled = true; -} + // Disable Undo and Redo + Edit1.IsUndoEnabled = false; + Edit1.IsRedoEnabled = false; + + // Uncomment to enable dynamic shortcut handling + // Edit1.PreviewKeyDown += Edit1_PreviewKeyDown; + } + + private void Edit1_PreviewKeyDown(object sender, KeyEventArgs e) + { + // Enable Undo only when Ctrl+Z is pressed + if (e.Key == Key.Z && (e.KeyboardDevice.Modifiers & ModifierKeys.Control) != 0) + { + Edit1.IsUndoEnabled = true; + } + } } ``` -This approach gives you full control over how shortcuts behave, allowing you to implement advanced scenarios such as enabling Undo only for certain operations or disabling it entirely in read-only modes. \ No newline at end of file +## Notes +- You can extend this logic to handle other shortcuts like Ctrl+Y, Ctrl+C, etc. +- Use PreviewKeyDown for intercepting before default behavior executes.