Posted 14 years ago
by Christel

Hi,
I focused a new problem:
I found now a solution to change the input text to upper case.
void Document_TextChanging(object sender, TextSnapshotChangingEventArgs e)
{
if (doFireChangeEvent && editor.ActiveView.HasFocus)
{
// Rekursion verhindern durch neues Ändern
doFireChangeEvent = false;
string changedtoTUpper = e.NewSnapshot.Text.ToUpper();
TextChangeOptions options = new TextChangeOptions();
// Changes must occur sequentially so that we can use unmodified
// offsets while looping over the document
options.OffsetDelta = TextChangeOffsetDelta.SequentialOnly;
// Prevent the caret from moving to the end of the text change in the
// active view
options.RetainSelection = true;
bool done = editor.Document.ReplaceText(TextChangeTypes.ChangeCase, editor.ActiveView.CurrentSnapshot.TextRange, changedtoTUpper, options);
doFireChangeEvent = true;
// Cancel the FirstKeyboard-Input which would overwrite the above
//change
e.Cancel = true;
}
}
But when I edit in the editor itself,
each time when I remove or add a letter, the caret jumps to the end of the whole text.
When I deactivate the cancel event by commenting out and removing a letter in the editor the caret retains it's position in the text BUT the editor scroll it to the beginning of the line.
Could you please help me with this suspicious behaviour?
Thanks!!
I focused a new problem:
I found now a solution to change the input text to upper case.
void Document_TextChanging(object sender, TextSnapshotChangingEventArgs e)
{
if (doFireChangeEvent && editor.ActiveView.HasFocus)
{
// Rekursion verhindern durch neues Ändern
doFireChangeEvent = false;
string changedtoTUpper = e.NewSnapshot.Text.ToUpper();
TextChangeOptions options = new TextChangeOptions();
// Changes must occur sequentially so that we can use unmodified
// offsets while looping over the document
options.OffsetDelta = TextChangeOffsetDelta.SequentialOnly;
// Prevent the caret from moving to the end of the text change in the
// active view
options.RetainSelection = true;
bool done = editor.Document.ReplaceText(TextChangeTypes.ChangeCase, editor.ActiveView.CurrentSnapshot.TextRange, changedtoTUpper, options);
doFireChangeEvent = true;
// Cancel the FirstKeyboard-Input which would overwrite the above
//change
e.Cancel = true;
}
}
But when I edit in the editor itself,
each time when I remove or add a letter, the caret jumps to the end of the whole text.
When I deactivate the cancel event by commenting out and removing a letter in the editor the caret retains it's position in the text BUT the editor scroll it to the beginning of the line.
Could you please help me with this suspicious behaviour?
Thanks!!