2

私は自分の WPF アプリケーションで Scintilla Text Editor を使用しています。ユーザーが空白のみを編集できるようにしたいと考えています: 挿入、削除、置換など。... どうすれば挿入/削除を防ぐことができますかe.Handled = true? 変更されたテキストを常に表すとは限らないため、これでは十分ではありません....次のコードを試しましたTextModifiedEventArgsKeyDown

  static void scintilla_BeforeTextModified(object sender, TextModifiedEventArgs e)
    {
        var scintilla = (Scintilla) sender;
        if (scintilla != null)
        {
            if (!string.IsNullOrWhiteSpace(scintilla.Selection.Text) || !string.IsNullOrWhiteSpace(e.Text))
            {
                // flag to ignore the change
                _ignoreTextChanges = true;
                // save text before modified
                _text = scintilla.Text;                  
            }  }

        }   private void _scintilla_TextChanged(object sender, EventArgs e)
    {
        if (!_suspendTextChanges)
        {
            _suspendTextChanges = true;
            if (_ignoreTextChanges)
            {
                _ignoreTextChanges = false;
                Text = _text;

                _scintilla.Text = _text;
            }
            else
            {
                Text = _scintilla.Text;
            }
            _suspendTextChanges = false;
        }
        _ignoreTextChanges = false;
    }   

しかし、設定したテキストが scintilla で変更されません... 誰か助けてくれませんか?

ありがとう...

4

0 に答える 0