AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.23k stars 2.19k forks source link

TextPresenter hides caret when there is non empty selection #16388

Open filipkunc opened 1 month ago

filipkunc commented 1 month ago

Is your feature request related to a problem? Please describe.

I have noticed that in TextPresenter has following logic on line 414:

if ((selectionStart != selectionEnd || !_caretBlink))
{
    return;
}

If I simply change it to:

if (!_caretBlink)
{
    return;
}

I see the caret also when there is a selection which helps me to understand if I am positioned at the start or at the end of the selection.

Describe the solution you'd like

I would like to have additional property on the TextBoxes and TextPresenter which would allow me to render the caret even when selection is empty. I also think this issue #12809 should also be fixed because it would be more noticeable when this is added.

Describe alternatives you've considered

I know the default TextBox in WPF behaves the same, but consider using something like Excel which also uses under the hood a custom text editing control for in-cell editing. There it also keeps the caret for richer behavior. Same goes for most "code" editing controls.

Additional context

No response

maxkatz6 commented 1 month ago

See https://github.com/AvaloniaUI/Avalonia/issues/16132 and https://github.com/AvaloniaUI/Avalonia/pull/15770. There was a relevant discussion about mobile support. Desktop might need different defaults as well.