Unverified Commit f0c4bc30 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Add SemanticService.tooltip method for Android tooltips (#16978)

parent 6334da01
......@@ -147,6 +147,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
_entry = new OverlayEntry(builder: (BuildContext context) => overlay);
Overlay.of(context, debugRequiredFor: widget).insert(_entry);
GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent);
SemanticsService.tooltip(widget.message);
_controller.forward();
return true;
}
......
......@@ -88,3 +88,22 @@ class AnnounceSemanticsEvent extends SemanticsEvent {
};
}
}
/// An event for a semantic announcement of a tooltip.
///
/// This is only used by Android to announce tooltip values.
class TooltipSemanticsEvent extends SemanticsEvent {
/// Constructs an event that triggers a tooltip announcement by the platform.
const TooltipSemanticsEvent(this.message) : super('tooltip');
/// The text content of the tooltip.
final String message;
@override
Map<String, dynamic> getDataMap() {
return <String, dynamic>{
'message': message,
};
}
}
......@@ -7,7 +7,7 @@ import 'dart:ui' show TextDirection;
import 'package:flutter/services.dart' show SystemChannels;
import 'semantics_event.dart' show AnnounceSemanticsEvent;
import 'semantics_event.dart' show AnnounceSemanticsEvent, TooltipSemanticsEvent;
/// Allows access to the platform's accessibility services.
......@@ -31,4 +31,12 @@ class SemanticsService {
final AnnounceSemanticsEvent event = new AnnounceSemanticsEvent(message, textDirection);
await SystemChannels.accessibility.send(event.toMap());
}
/// Sends a semantic announcement of a tooltip.
///
/// This is only used by Android.
static Future<Null> tooltip(String message) async {
final TooltipSemanticsEvent event = new TooltipSemanticsEvent(message);
await SystemChannels.accessibility.send(event.toMap());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment