AvaloniaEdit icon indicating copy to clipboard operation
AvaloniaEdit copied to clipboard

Hovering over hyperlinks results in permanent hand cursor over control, and click not working.

Open nnaaa-vr opened this issue 3 years ago • 4 comments

Tested with latest NuGet package (0.10.0) of AvalonEdit as well as a build of the branch as of today. Avalonia version is 0.10.2 (nuget).

I've enabled hyperlinks, and now whenever my mouse encounters a hyperlink on the control, from that point forward any time the mouse is hovering over the edit control (over the hyperlink or not), it's the hand cursor not the arrow cursor. Clicking the hyperlink is also not functioning.

My TextEditorOptions: EventLog.Options.EnableHyperlinks = true; EventLog.Options.RequireControlModifierForHyperlinkClick = false;

My editor XAML: <ae:TextEditor Name="EventLog" Height="390" Width="565" Margin="5" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" IsReadOnly="True" SyntaxHighlighting="EventLogSH" />

nnaaa-vr avatar Apr 29 '21 17:04 nnaaa-vr

For clicks, it seems that we need to add and implement an event handler.

EventLog.AddHandler(AvaloniaEdit.Rendering.VisualLineLinkText.OpenUriEvent, (s, e) => {
    var url = e.Uri;
    // It checks on windows only.
    // If you want to run on another system, see https://github.com/dotnet/runtime/issues/17938
    Process.Start(new ProcessStartInfo { FileName = url.ToString(), UseShellExecute = true });
});

whistyun avatar May 23 '21 14:05 whistyun

For clicks, it seems that we need to add and implement an event handler.

EventLog.AddHandler(AvaloniaEdit.Rendering.VisualLineLinkText.OpenUriEvent, (s, e) => {
    var url = e.Uri;
    // It checks on windows only.
    // If you want to run on another system, see https://github.com/dotnet/runtime/issues/17938
    Process.Start(new ProcessStartInfo { FileName = url.ToString(), UseShellExecute = true });
});

This seems to work, and I see your commit for fixing the cursor. Only issue for me now, is that the default link regex in LinkElementGenerator is designed to exclude punctuation at the end of a URI, and most of the links in my use case end with a ')' character that is being excluded. Forking and fixing myself for now, as that character is absolutely necessary.

Thanks!

nnaaa-vr avatar May 23 '21 16:05 nnaaa-vr

Partially fixed here (already merged): https://github.com/AvaloniaUI/AvaloniaEdit/pull/157/commits/8bfc3d984da727d756ac53023dcd140211eeda48

Not fully fixed cause I noticed that Avalonia doesn't doesn't fill the PointerEventArgs.KeyModifiers properly when processing OnPointerMoved.

For example, moving the mouse hover a control with the left Control key pressed, when OnPointerMoved , is called, the PointerEventArgs.KeyModifiers is None. I reproduce it on Windows platform. Afaik it works fine in macOS.

Curious that once you perform a pointer click holding the Ctrl key, then the subsequent PointerMoved events sends the PointerEventArgs.KeyModifiers properly.

danipen avatar Dec 07 '21 08:12 danipen

Hi, any news here? That would be helpful to fix: https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/0079c13e32c5eb794efd37739a146ca6b47db0f6/src/StructuredLogViewer.Avalonia/Controls/ImportLinkHighlighter.cs#L141

Janek91 avatar May 09 '24 07:05 Janek91