Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF Cut Functionality Issue

$
0
0

Hi,

I have to override existing windows CUT functionality in my application because I have to update something before I CUT data from TextObject. So I used belo code to achieve that.

       protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            base.OnPreviewKeyDown(e);
            bool isCtrlKeyDown = (Keyboard.Modifiers & ModifierKeys.Control) != 0;

            //KeyBoard short cut for textformatting.
            if (isCtrlKeyDown && (e.Key == Key.X))
            {
                switch (e.Key)
                {
                     case Key.X:
                        SetSelectedTextForCut();/// This needs to be called before I CUT
                        if (ApplicationCommands.Cut.CanExecute(null, this))
                            ApplicationCommands.Cut.Execute(null, this);
                        base.OnPreviewKeyDown(e);
                        break;
                }
                e.Handled = true;
            }
        }

But Issue is, becoz I override this, my text is not performing actual CUT operation, It's performing SetSelectedTextForCut() this,  also does this : ApplicationCommands.Cut.Execute(null, this); but not cutting text from textobject. 

Please let me know what I am doing wrong here? If i dont override then it works fine. 

Thanks

Dee


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>