|
|
|
@ -369,6 +369,14 @@ namespace Avalonia.Controls |
|
|
|
get { return _newLine; } |
|
|
|
set { SetAndRaise(NewLineProperty, ref _newLine, value); } |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Clears the current selection, maintaining the <see cref="CaretIndex"/>
|
|
|
|
/// </summary>
|
|
|
|
public void ClearSelection() |
|
|
|
{ |
|
|
|
SelectionStart = SelectionEnd = CaretIndex; |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) |
|
|
|
{ |
|
|
|
@ -413,8 +421,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
if (ContextMenu == null || !ContextMenu.IsOpen) |
|
|
|
{ |
|
|
|
SelectionStart = 0; |
|
|
|
SelectionEnd = 0; |
|
|
|
ClearSelection(); |
|
|
|
RevealPassword = false; |
|
|
|
} |
|
|
|
|
|
|
|
@ -444,7 +451,7 @@ namespace Avalonia.Controls |
|
|
|
text = Text ?? string.Empty; |
|
|
|
SetTextInternal(text.Substring(0, caretIndex) + input + text.Substring(caretIndex)); |
|
|
|
CaretIndex += input.Length; |
|
|
|
SelectionStart = SelectionEnd = CaretIndex; |
|
|
|
ClearSelection(); |
|
|
|
_undoRedoHelper.DiscardRedo(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -662,7 +669,7 @@ namespace Avalonia.Controls |
|
|
|
SetTextInternal(text.Substring(0, caretIndex - removedCharacters) + |
|
|
|
text.Substring(caretIndex)); |
|
|
|
CaretIndex -= removedCharacters; |
|
|
|
SelectionStart = SelectionEnd = CaretIndex; |
|
|
|
ClearSelection(); |
|
|
|
} |
|
|
|
_undoRedoHelper.Snapshot(); |
|
|
|
|
|
|
|
@ -735,7 +742,7 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
else if (movement) |
|
|
|
{ |
|
|
|
SelectionStart = SelectionEnd = CaretIndex; |
|
|
|
ClearSelection(); |
|
|
|
} |
|
|
|
|
|
|
|
if (handled || movement) |
|
|
|
@ -1042,7 +1049,8 @@ namespace Avalonia.Controls |
|
|
|
var end = Math.Max(selectionStart, selectionEnd); |
|
|
|
var text = Text; |
|
|
|
SetTextInternal(text.Substring(0, start) + text.Substring(end)); |
|
|
|
SelectionStart = SelectionEnd = CaretIndex = start; |
|
|
|
CaretIndex = start; |
|
|
|
ClearSelection(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
else |
|
|
|
@ -1131,7 +1139,8 @@ namespace Avalonia.Controls |
|
|
|
set |
|
|
|
{ |
|
|
|
Text = value.Text; |
|
|
|
SelectionStart = SelectionEnd = CaretIndex = value.CaretPosition; |
|
|
|
CaretIndex = value.CaretPosition; |
|
|
|
ClearSelection(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|