|
|
|
@ -396,6 +396,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; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Property for determining if the Cut command can be executed.
|
|
|
|
@ -479,8 +487,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
if (ContextMenu == null || !ContextMenu.IsOpen) |
|
|
|
{ |
|
|
|
SelectionStart = 0; |
|
|
|
SelectionEnd = 0; |
|
|
|
ClearSelection(); |
|
|
|
RevealPassword = false; |
|
|
|
} |
|
|
|
|
|
|
|
@ -512,7 +519,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(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -737,7 +744,7 @@ namespace Avalonia.Controls |
|
|
|
SetTextInternal(text.Substring(0, caretIndex - removedCharacters) + |
|
|
|
text.Substring(caretIndex)); |
|
|
|
CaretIndex -= removedCharacters; |
|
|
|
SelectionStart = SelectionEnd = CaretIndex; |
|
|
|
ClearSelection(); |
|
|
|
} |
|
|
|
_undoRedoHelper.Snapshot(); |
|
|
|
|
|
|
|
@ -810,7 +817,7 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
else if (movement) |
|
|
|
{ |
|
|
|
SelectionStart = SelectionEnd = CaretIndex; |
|
|
|
ClearSelection(); |
|
|
|
} |
|
|
|
|
|
|
|
if (handled || movement) |
|
|
|
@ -1117,7 +1124,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 |
|
|
|
@ -1206,7 +1214,8 @@ namespace Avalonia.Controls |
|
|
|
set |
|
|
|
{ |
|
|
|
Text = value.Text; |
|
|
|
SelectionStart = SelectionEnd = CaretIndex = value.CaretPosition; |
|
|
|
CaretIndex = value.CaretPosition; |
|
|
|
ClearSelection(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|