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

Implement double/triple/quadruple click in TextArea #5405

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Dec 17, 2024

Note to self: Fix the behaviour when you click on whitespace.

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one thing for your consideration

@@ -1612,6 +1642,17 @@ async def _on_hide(self, event: events.Hide) -> None:
"""Finalize the selection that has been made using the mouse when the widget is hidden."""
self._end_mouse_selection()

async def on_click(self, event: events.Click) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this shouldn't use modulus. It doesn't look like vscode wraps the click chain in this way.

Copy link
Member Author

@darrenburns darrenburns Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Experimented with this. For now wrapping works better for us for reasons™.

Without the modulus here, when we get to chain == 5 and above, the selection goes back to being a cursor and it appears the click chaining stops working. I think the wrapping behaviour feels better than this, although I think the end-goal should be replicating VSCode's approach of doing nothing on the additional clicks and keeping the whole document selected, but that's just a bit tricky for now...

I think VSCode does chaining on the "mouse down" event. This would let us do a better implementation of this and remove a subtle flicker (between chain 2 and 3, the selection disappears briefly as we set the location in the mouse down handler, then the click handler fires later and selects the line). While we only have it on the click event, it's very difficult to replicate their behaviour exactly.

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 this pull request may close these issues.

2 participants