Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Modifier keys state should also be synchronized based on pointer events #115066

Closed
@bleroux

Description

@bleroux

On Desktop and Web, Flutter maintains keyboard state based on key events received when the window has focus.
If a keyboard event happens when the window has lost focus, Flutter keyboard state is not updated.
This leads to visible bugs, especially ones related to modifier keys. See #112488

Steps to Reproduce

  1. Launch the below code sample.
  2. Enter some test in the text field.
  3. Click somewhere on the text.
  4. Hold shift key pressed.
  5. While holding the shift key, click somewhere else on the text, the text between both click positions is selected.
  6. While holding the shift key, click on another window (Flutter window loses focus).
  7. Release the shift key.
  8. Click inside the text field.

Expected results: At step 8, the click should just move the cursor and no text should be selected

Actual results: At step 8, the click updates the selection (as the shift key was still pressed).

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Container(
          alignment: Alignment.center,
          padding: const EdgeInsets.all(16),
          child: const TextField(),
        ),
      ),
    );
  }
}

As per this discussion, the modifier keys states should be also updated based on pointer events (which contain a modifier state property).

This should be implemented on the engine side for:

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsengineflutter/engine repository. See also e: labels.platform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions