Option to disable right click select on selectable text, but keep it selectable with left click #148045
Labels
a: mouse
Issues related to using a mouse or mouse support
c: proposal
A detailed proposal for a change to Flutter
f: selection
SelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIs
framework
flutter/packages/flutter repository. See also f: labels.
P3
Issues that are less important to the Flutter project
team-framework
Owned by Framework team
triaged-framework
Triaged by Framework team
Use case
Consider the following widget:
The user can select the selectable text with left click, and a right click on the red container prints "I was tapped". However, a right click on the selectable text selects the clicked on word instead of printing "I was tapped".
Screen.Recording.2024-05-09.at.11.40.09.mov
Setting
enableInteractiveSelection
tofalse
makes the text un-selectable, but also ignores the right click.Obviously, same behaviour when wrapping
SelectableText
inAbsorbPointer
orIgnorePointer
.I also tried creating a custom
AbsorbRightClickPointer
widget, however as far as I can tell, it is not possible to get the pointer type inRenderBox.hitTest
.Without this it is not possible to implement for example a custom context menu, that opens both when right-clicking the red container and the text inside as it is done in Telegram Desktop:
Screen.Recording.2024-05-09.at.11.38.18.mov
Proposal
Make it possible to disable or adjust the right click behaviour of selectable text.
The text was updated successfully, but these errors were encountered: