Unverified Commit 7467bde4 authored by creativecreatorormaybenot's avatar creativecreatorormaybenot Committed by GitHub

Add Gamepad support for the activation action (#49987)

parent 52d5744e
......@@ -847,6 +847,7 @@ class WidgetsApp extends StatefulWidget {
// Activation
LogicalKeySet(LogicalKeyboardKey.enter): const Intent(ActivateAction.key),
LogicalKeySet(LogicalKeyboardKey.space): const Intent(ActivateAction.key),
LogicalKeySet(LogicalKeyboardKey.gameButtonA): const Intent(ActivateAction.key),
// Keyboard traversal.
LogicalKeySet(LogicalKeyboardKey.tab): const Intent(NextFocusAction.key),
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
......@@ -96,6 +97,48 @@ void main() {
expect(action.calls, equals(1));
});
testWidgets('WidgetsApp default activation key mappings work', (WidgetTester tester) async {
bool checked = false;
await tester.pumpWidget(
WidgetsApp(
builder: (BuildContext context, Widget child) {
return Material(
child: Checkbox(
value: checked,
autofocus: true,
onChanged: (bool value) {
checked = value;
},
),
);
},
color: const Color(0xFF123456),
),
);
await tester.pump();
// Test three default buttons for the activation action.
await tester.sendKeyEvent(LogicalKeyboardKey.space);
await tester.pumpAndSettle();
expect(checked, isTrue);
// Only space is used as an activation key on web.
if (kIsWeb) {
return;
}
checked = false;
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(checked, isTrue);
checked = false;
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonA);
await tester.pumpAndSettle();
expect(checked, isTrue);
});
group('error control test', () {
Future<void> expectFlutterError({
GlobalKey<NavigatorState> key,
......
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