Markdown.Avalonia icon indicating copy to clipboard operation
Markdown.Avalonia copied to clipboard

Issue with text selection when content is scrolled

Open cezarypiatek opened this issue 2 years ago • 6 comments

When the markdown is scrolled down, then selection behaves in a strange way - content is scrolled automatically to the top and random text gets selected. WireMockInspector_hpoqMYSK0e

Avalonia 11.0.0-preview6 Markdown.Avalonia 11.0.0-b1

cezarypiatek avatar May 08 '23 16:05 cezarypiatek

When the markdown is scrolled down, then selection behaves in a strange way - content is scrolled automatically to the top and random text gets selected. WireMockInspector_hpoqMYSK0e WireMockInspector_hpoqMYSK0e

Avalonia 11.0.0-preview6 Markdown.Avalonia 11.0.0-b1

How do you add the line number one the left? Could I have refer it?

dayAndnight2018 avatar Sep 22 '23 05:09 dayAndnight2018

@dayAndnight2018

                    <Style Selector="avedit|TextEditor">
                        <Style.Setters>
                            <Setter Property="ShowLineNumbers" Value="True" />
                        </Style.Setters>
                    </Style>

oskar-ziller avatar Nov 30 '23 12:11 oskar-ziller

I'm also struggling with this, any chance this can be looked into?

oskar-ziller avatar Nov 30 '23 12:11 oskar-ziller

I'm trying to display Markdown text as shown in the binding example, but in this case, I can't select the text. Can you please advise on how to resolve this issue?

<md:MarkdownScrollViewer Markdown="{Binding MdText}"/>

PhillBang avatar Dec 02 '23 13:12 PhillBang

@PhillBang You can only select text in AvaloniaEdit.TextEditor from my experience.

oskar-ziller avatar Dec 02 '23 15:12 oskar-ziller

I solved it by overriding RequestBringIntoViewEvent event:

	public class CustomMarkdownScrollViewer : Markdown.Avalonia.MarkdownScrollViewer
	{
		public CustomMarkdownScrollViewer()
		{
			Plugins = new MdAvPlugins();
			AddHandler(RequestBringIntoViewEvent, OnRequestBringIntoView, handledEventsToo: true);
		}

		private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
		{
			e.Handled = true;
		}

		protected override void OnPointerPressed(PointerPressedEventArgs e)
		{
			base.OnPointerPressed(e);
			// Optionally, handle pointer pressed event to prevent focus
			e.Handled = true;
		}
	}

oskar-ziller avatar Dec 26 '23 11:12 oskar-ziller