Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nnaaa-vr opened this issue Apr 29, 2021 · 4 comments

Comments

@nnaaa-vr
Copy link

nnaaa-vr commented Apr 29, 2021

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" />

@whistyun
Copy link
Contributor

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 added a commit to whistyun/AvaloniaEdit that referenced this issue May 23, 2021
@nnaaa-vr
Copy link
Author

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!

@danipen
Copy link
Collaborator

danipen commented Dec 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants