-
Notifications
You must be signed in to change notification settings - Fork 250
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
base: main
Are you sure you want to change the base?
Conversation
super_editor/lib/src/super_textfield/android/_user_interaction.dart
Outdated
Show resolved
Hide resolved
super_editor/lib/src/super_textfield/android/android_textfield.dart
Outdated
Show resolved
Hide resolved
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
...editor/lib/src/super_textfield/infrastructure/text_field_gestures_interaction_overrides.dart
Outdated
Show resolved
Hide resolved
super_editor/test/super_textfield/super_textfield_gestures_interaction_overrides_test.dart
Outdated
Show resolved
Hide resolved
@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) ? |
@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. |
c790e7f
to
308a7c2
Compare
[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
'sContentTapDelegate
.I noticed we also have a
RightClickListener
. We could probably deprecate this property and make everything available through the newSuperTextFieldTapHandler
.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.