PerformTextInput() 공개 메소드

Performs text input. This raises the TextEntering event, replaces the selection with the text, and then raises the TextEntered event.
public PerformTextInput ( System.Windows.Input.TextCompositionEventArgs e ) : void
e System.Windows.Input.TextCompositionEventArgs
리턴 void
예제 #1
0
        static void OnEnter(object target, ExecutedRoutedEventArgs args)
        {
            TextArea textArea = GetTextArea(target);

            if (textArea != null && textArea.IsKeyboardFocused)
            {
                textArea.PerformTextInput("\n");
                args.Handled = true;
            }
        }
예제 #2
0
        static void OnEnter(object target, ExecutedRoutedEventArgs args)
        {
            TextArea textArea = GetTextArea(target);

            if (textArea != null && textArea.IsKeyboardFocused)
            {
                // [DIGITALRUNE] Enter MUST NOT be handled when another control has the focus.
                // Note: OnEnter is called via CommandBinding with KeyGesture = Enter.
                if (!textArea.IsKeyboardFocused)
                {
                    return;
                }

                textArea.PerformTextInput("\n");
                args.Handled = true;
            }
        }
예제 #3
0
        private static void OnEnter(object target, ExecutedRoutedEventArgs args)
        {
            TextArea textArea = GetTextArea(target);

            if (textArea != null && textArea.IsKeyboardFocused)
            {
                textArea.PerformTextInput("\n");
                var a = textArea.Document.GetLineByOffset(textArea.Caret.Offset);
                var b = a.PreviousLine;
                if (b == null)
                {
                    return;
                }
                var c = b.PreviousLine;
                if (c == null)
                {
                    return;
                }
                if (c.obs != null)
                {
                    var obs = c.obs;
                    var bs  = textArea.Document.Text.Substring(b.Offset, b.Length + b.DelimiterLength);
                    if (!string.IsNullOrWhiteSpace(bs))
                    {
                        var cs = textArea.Document.Text.Substring(c.Offset, c.Length + c.DelimiterLength);
                        textArea.Document.Remove(c.Offset, bs.Length + cs.Length);
                    }
                    else
                    {
                        var cs = textArea.Document.Text.Substring(c.Offset, c.Length + c.DelimiterLength);
                        textArea.Document.Remove(c.Offset, bs.Length + cs.Length);
                        textArea.Document.Insert(c.Offset, bs + cs);
                        a     = textArea.Document.GetLineByOffset(textArea.Caret.Offset);
                        b     = a.PreviousLine;
                        b.obs = obs;
                    }
                }
                args.Handled = true;
            }
        }