question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] SelectableTextBlock SelectionStart-/End incorrect in some Scenarios

See original GitHub issue

Normally when clicked outside the Text in a SelectableTextBlock the SelectionStart and SelectionEnd properties are set to the last character index + 1. So just outside the Text. For the Text “Test” SelectionStart will be 4 when the user clicks somewhere outside the Text.

Also normally if there are multiple lines in the SelectableTextBlock and a letter (or word) not in the first line is selected, SelectionStart is just the index of that letter (or word) as if there were no linebreaks (each linebreak is just \r\n so this adds 2 Characters per linebreak).

But when there are multiple lines and the user clicks outside the Text, I would expect SelectionStart to be either the last index in that line (the line where the user clicked) or just the last index of the whole Text. But instead it is the last index of the first line.

Examples: “Test” -> click outside will set index to 4

“Test -> click on “s” in second line will set index to 8 (because line break is \r\n so 2 characters, 8 - 2 would be 6 -> so that’s correct) Test”

“Test -> click outside in line 1 will set index to 4 (which is still correct) Test”

“Test -> click outside in line 2 will still set index to 4 (expected would be 10, 10 -2 cause of line break would be 8 so just after the last “t”) Test”

Desktop information

  • OS: Windows 11
  • Avalonia Version: 11.0.0-rc1.1

I hope that this is understandable, it’s difficult to explain

Issue Analytics

  • State:open
  • Created 3 months ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
timuniecommented, Aug 15, 2023

@nuc134r setting Background=Transparent should also work, as transparent is totally valid background for hit-testing. But the default null will not work as it it not hittestable.

@Gillibald do we maybe want to add Transparent by default to make it work for everyone?

0reactions
Gillibaldcommented, Aug 15, 2023

@nuc134r setting Background=Transparent should also work, as transparent is totally valid background for hit-testing. But the default null will not work as it it not hittestable.

@Gillibald do we maybe want to add Transparent by default to make it work for everyone?

Yes we need to fallback to transparent instead of leaving the brush null

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found