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

CompletionWindow doesn't work with mouse click #413

Closed
NickRimmer opened this issue Apr 16, 2024 · 9 comments · Fixed by #414
Closed

CompletionWindow doesn't work with mouse click #413

NickRimmer opened this issue Apr 16, 2024 · 9 comments · Fixed by #414

Comments

@NickRimmer
Copy link

Hey community,

I found strange behavior. When CompletionWindow opened, you can select variants by keyboard up/down and press enter - everything working as expected. But if you will open it and select option by mouse - it will just close CompletionWindow and do nothing.

How can we make it works by mouse selection as well?

How to reproduce

  • clone AvaloniaEdit master branch
  • run AvalolinaEdit.Demo project
  • in some place try to write something like asd. to show CompletionWindow
  • click to any of items by mouse

image

@mgarstenauer
Copy link
Contributor

I looked at the code and found this TODO:

Shouldn't be too hard to fix. Preparing a PR now...

What is the expected behavior? Do we want to insert the item on a single-click or a double-click? Most modern editors insert items with a single-click. IIRC, the original AvalonEdit used a double-click. I am going to implement single-click for now.

mgarstenauer added a commit to garstenauer/AvaloniaEdit that referenced this issue Apr 17, 2024
danipen added a commit that referenced this issue Apr 19, 2024
Fix: #413 CompletionWindow doesn't work with mouse click
@NickRimmer
Copy link
Author

Thank you so much for quick review @danipen.
@MarchingCube thank you for great fix 🎉

@gebodal
Copy link

gebodal commented Aug 10, 2024

Apologies for being difficult, resurrecting an old issue, but it would be great if the single/double click was configurable somehow. There doesn't seem to be a particularly clean way of overloading these classes to change the behaviour, as the AddHandler(...) is embedded in the class constructor, so an option would be great.

@mgarstenauer
Copy link
Contributor

What would be the motivation for using double-click instead of single-click?

@gebodal
Copy link

gebodal commented Aug 11, 2024

The motivation for me would be that the ListBox is a SelectingItemsControl, and the fact that the selection works with the arrow keys but not the mouse pointer breaks the affordance (had to look up the technical term there) of the control. It also doesn't seem consistent across the various interactions. And, as the action now triggers on PointerPressed rather than PointerReleased or DoubleTapped, the action occurs sooner than expected, which slightly diminishes recoverability for user input.

As an example, Visual Studio uses a single-click for selecting items in the autocomplete dropdown, and double-click for activating a given autocomplete option.

@mgarstenauer
Copy link
Contributor

I'll look into it.

@mgarstenauer
Copy link
Contributor

@gebodal I don't see a simple way to support DoubleTapped. The ListBoxItem consumes the first click when it is not selected. The DoubleTapped event (or PointerPressedEvent with ClickCount == 2) only fires when the ListBoxItem is already selected. That means, you would need to triple-click in most cases.

The current implementation (PointerPressed) behaves the same as ReSharper or VS Code. Perhaps there is an simple way to make DoubleTapped work as well, but I am not aware of it.

@mgarstenauer
Copy link
Contributor

After further digging: I was wrong about the ListBoxItem. It does not prevent the DoubleTapped event from being fired. Showing the completion item's tool-tip prevents the DoubleTapped event from being fired. (Opening the PopupWithCustomPosition seems to reset the double-click logic.)

@mgarstenauer
Copy link
Contributor

Had some time today to look at this again and found a solution. There is now an option to choose whether to insert the completion item on PointerPressed, PointerReleased, or DoubleTapped.

@gebodal Can you test #451?

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

Successfully merging a pull request may close this issue.

3 participants