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

[SuperTextField] Add ability to override tap gestures (Resolves #2447) #2455

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

angelosilvestre
Copy link
Collaborator

[SuperTextField] Add ability to override tap gestures. Resolves #2447

This PR allows apps to register custom handlers, to enable features like changing the mouse cursor when hovering content with specific attributions, like a LinkAttribution and performing custom logic when tapping on it.

The implementation is based on the SuperEditor's ContentTapDelegate.

I noticed we also have a RightClickListener. We could probably deprecate this property and make everything available through the new SuperTextFieldTapHandler.

This PR includes a SuperTextFieldLaunchLinkTapHandler that changes the mouse cursor when hovering a link, and opens the URL when tapping on it.

On SuperEditor, we have the concept of "interaction mode", which is enabled when the users presses CMD. The mouse cursor and tap handling on the link handler only runs if the editor is in interaction mode. This is not yet implemented by this PR, because the original ticket didn't mention it. If it's needed, we can add that.

import 'package:super_editor/super_text_field.dart';
import 'package:super_text_layout/super_text_layout.dart';

/// Delegate for mouse status and clicking on special types of content,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace with:

/// Tap handler that can (optionally) respond to single, double, and triple taps, as well as dictate the cursor
/// appearance on desktop.

I also want to add a section about listening, but after reviewing the code that registers as a listener, I'm not actually sure how the change notifications are supposed to work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also want to add a section about listening, but after reviewing the code that registers as a listener, I'm not actually sure how the change notifications are supposed to work?

On SuperEditor, we have the concept on interaction mode in the document composer, when the user presses CMD the interaction mode is enabled. The SuperEditorLaunchLinkTapHandler listens for interaction mode changes and notifies its own listeners when a change happens.

On SuperTextField, we don't yet have an interaction mode, nor a composer. It's not clear to me where this should be handled.

@matthew-carroll
Copy link
Contributor

I noticed we also have a RightClickListener. We could probably deprecate this property and make everything available through the new SuperTextFieldTapHandler.

Ok, let's go ahead and deprecate.

BTW, while we're here on this ticket, can we also offer right-click support?

#278

#692

@angelosilvestre
Copy link
Collaborator Author

@matthew-carroll Since #278 mentions tap down vs tap up events, should we provide down/up variations for the all tap handlers (single tap, double tap, triple tap) ?

@angelosilvestre
Copy link
Collaborator Author

@matthew-carroll Added support for right click on the tap handlers. To be flexible, we should probably offer the down, up and cancel callbacks for each event.

@angelosilvestre angelosilvestre force-pushed the 2447_textfield-custom-tap-handlers branch from c790e7f to 308a7c2 Compare December 20, 2024 13:09
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.

[FEATURE] - [SuperTextField] Allow LinkAttributions to be clickable
2 participants