Fix for right-click on message bubbles (right click didn't work on the actual text of the bubble)

This commit is contained in:
Eric Poulsen
2026-06-13 19:05:52 -07:00
parent c867225073
commit f1478722b0
4 changed files with 20 additions and 1 deletions
+10 -1
View File
@@ -20,6 +20,7 @@ class LinkHandler {
required String text,
required TextStyle style,
TextStyle? linkStyle,
VoidCallback? onSecondaryTap,
}) {
final effectiveLinkStyle = linkStyle ?? defaultLinkStyle(context, style);
const options = LinkifyOptions(humanize: false, defaultToHttps: false);
@@ -27,7 +28,7 @@ class LinkHandler {
void onOpen(LinkableElement link) => handleLinkTap(context, link.url);
if (PlatformInfo.isDesktop) {
return SelectableLinkify(
final linkify = SelectableLinkify(
text: text,
style: style,
linkStyle: effectiveLinkStyle,
@@ -35,6 +36,14 @@ class LinkHandler {
linkifiers: linkifiers,
onOpen: onOpen,
);
if (onSecondaryTap == null) return linkify;
return Listener(
onPointerDown: (event) {
if (event.buttons == 2) onSecondaryTap();
},
behavior: HitTestBehavior.translucent,
child: linkify,
);
}
return Linkify(
text: text,
+3
View File
@@ -646,6 +646,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
fontStyle: FontStyle.italic,
color: textColor.withValues(alpha: 0.72),
),
onSecondaryTap: PlatformInfo.isDesktop
? () => _showMessageActions(message)
: null,
),
),
],
+3
View File
@@ -1435,6 +1435,9 @@ class _MessageBubble extends StatelessWidget {
color: textColor.withValues(alpha: 0.72),
fontSize: bodyFontSize * textScale,
),
onSecondaryTap: PlatformInfo.isDesktop
? onLongPress
: null,
),
),
],
@@ -8,6 +8,7 @@ class TranslatedMessageContent extends StatelessWidget {
final TextStyle style;
final TextStyle? originalStyle;
final bool showOriginalFirst;
final VoidCallback? onSecondaryTap;
const TranslatedMessageContent({
super.key,
@@ -16,6 +17,7 @@ class TranslatedMessageContent extends StatelessWidget {
this.originalText,
this.originalStyle,
this.showOriginalFirst = true,
this.onSecondaryTap,
});
@override
@@ -36,12 +38,14 @@ class TranslatedMessageContent extends StatelessWidget {
fontStyle: FontStyle.italic,
fontSize: style.fontSize,
),
onSecondaryTap: onSecondaryTap,
)
: null;
final translatedWidget = LinkHandler.buildLinkifyText(
context: context,
text: trimmedDisplay,
style: style,
onSecondaryTap: onSecondaryTap,
);
if (!shouldShowOriginal) {