Hovering over hyperlinks results in permanent hand cursor over control, and click not working.
nnaaa-vr opened this issue · 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" />
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 });
});
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!
Partially fixed here (already merged):
8bfc3d9
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.
Hi, any news here? That would be helpful to fix:
https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/0079c13e32c5eb794efd37739a146ca6b47db0f6/src/StructuredLogViewer.Avalonia/Controls/ImportLinkHighlighter.cs#L141