Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard does not work in Flutter Windows #54226

Closed
TheCGDF opened this issue Apr 7, 2020 · 4 comments · Fixed by flutter/engine#17706
Closed

Clipboard does not work in Flutter Windows #54226

TheCGDF opened this issue Apr 7, 2020 · 4 comments · Fixed by flutter/engine#17706
Assignees
Labels
a: desktop Running on desktop engine flutter/engine repository. See also e: labels. platform-windows Building on or for Windows specifically

Comments

@TheCGDF
Copy link

TheCGDF commented Apr 7, 2020

Steps to Reproduce

  1. Clipboard.setData(ClipboardData(text: "abc"));

  2. Paste in notepad or somewhere else.

Or:

  1. Copy something form notepad or somewhere else.

  2. Paste it in Flutter TextField

Expected results:
Paste/Copy

Actual results:
Flutter's clipboard works individually with Windows system. It cannot copy something to Windows clipboard. And when trying copy some from Windows to Flutter TextField, only garbled pasted.
gen_pass_Gsb4vlr64v

Logs
flutter analyze
Analyzing gen_pass...
No issues found! (ran in 1.7s)
flutter doctor -v
[√] Flutter (Channel master, v1.18.0, on Microsoft Windows [Version 10.0.17763.1039], locale en-US)
    • Flutter version 1.18.0 at D:\Software\flutter
    • Framework revision 8f7327f83a (18 hours ago), 2020-04-06 22:11:01 -0400
    • Engine revision 49891e0653
    • Dart version 2.8.0 (build 2.8.0-dev.20.0 1210d27678)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at D:\Software\AndroidSDK
    • Platform android-29, build-tools 29.0.2
    • Java binary at: D:\Software\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[X] Chrome - develop for the web (Cannot find chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2019 16.5.0)
    • Visual Studio at D:\Software\VS2019
    • Visual Studio Enterprise 2019 version 16.5.29911.84

[√] Android Studio (version 3.6)
    • Android Studio at D:\Software\Android Studio
    • Flutter plugin version 45.0.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] Connected device (2 available)
    • Windows    • Windows    • windows-x64    • Microsoft Windows [Version 10.0.17763.1039]
    • Web Server • web-server • web-javascript • Flutter Tools
@stuartmorgan
Copy link
Contributor

I take it the text you are copying and pasting in that screenshot is not ASCII?

Looking at the code and the docs, we're using CF_TEXT, but passing UTF-8, which isn't correct. We should do a UTF-8/UTF-16 conversion and use CF_UNICODETEXT instead.

@stuartmorgan stuartmorgan added a: desktop Running on desktop engine flutter/engine repository. See also e: labels. platform-windows Building on or for Windows specifically labels Apr 7, 2020
@TheCGDF
Copy link
Author

TheCGDF commented Apr 7, 2020

I take it the text you are copying and pasting in that screenshot is not ASCII?

Looking at the code and the docs, we're using CF_TEXT, but passing UTF-8, which isn't correct. We should do a UTF-8/UTF-16 conversion and use CF_UNICODETEXT instead.

Whatever I copied, when i paste it to Flutter TextField, it will always be a single garbled character.

@minhcasi
Copy link

I have the same problem on Window, please help to fix it!

@stuartmorgan stuartmorgan self-assigned this Apr 14, 2020
stuartmorgan added a commit to stuartmorgan/engine that referenced this issue Apr 14, 2020
Fixes several bugs in the clipboard code, and makes some structural
improvements:
- Adds scoped wrappers for clipboard open/close and global lock/unlock,
  to prevent missing cleanup, fixing at least one case where the lock
  was not released.
- Adds the relevant window handle to the clipboard calls, since the docs
  suggest that some operations won't work without one.
- Adds a missing clear step to setting the clipboard data.
- Switches from TEXT to UNICODETEXT to handle non-ASCII text correctly.
  - To enable that, adds UTF-16/-8 conversion utilities built on the
    Win32 APIs (rather than the deprecated std::codecvt functions, as
    have been previously used in the engine).
- Fixes handling of getting data when the clipboard is empty, correctly
  returning null.
- Passes more errors back through the method channel, with details, for
  easier debugging of future issues.

Fixes flutter/flutter#54226
stuartmorgan added a commit to flutter/engine that referenced this issue Apr 15, 2020
Fixes several bugs in the clipboard code, and makes some structural
improvements:
- Adds scoped wrappers for clipboard open/close and global lock/unlock,
  to prevent missing cleanup, fixing at least one case where the lock
  was not released.
- Adds the relevant window handle to the clipboard calls, since the docs
  suggest that some operations won't work without one.
- Adds a missing clear step to setting the clipboard data.
- Switches from TEXT to UNICODETEXT to handle non-ASCII text correctly.
  - To enable that, adds UTF-16/-8 conversion utilities built on the
    Win32 APIs (rather than the deprecated std::codecvt functions, as
    have been previously used in the engine).
- Fixes handling of getting data when the clipboard is empty, correctly
  returning null.
- Passes more errors back through the method channel, with details, for
  easier debugging of future issues.

Fixes flutter/flutter#54226
goderbauer pushed a commit to goderbauer/engine that referenced this issue Apr 16, 2020
Fixes several bugs in the clipboard code, and makes some structural
improvements:
- Adds scoped wrappers for clipboard open/close and global lock/unlock,
  to prevent missing cleanup, fixing at least one case where the lock
  was not released.
- Adds the relevant window handle to the clipboard calls, since the docs
  suggest that some operations won't work without one.
- Adds a missing clear step to setting the clipboard data.
- Switches from TEXT to UNICODETEXT to handle non-ASCII text correctly.
  - To enable that, adds UTF-16/-8 conversion utilities built on the
    Win32 APIs (rather than the deprecated std::codecvt functions, as
    have been previously used in the engine).
- Fixes handling of getting data when the clipboard is empty, correctly
  returning null.
- Passes more errors back through the method channel, with details, for
  easier debugging of future issues.

Fixes flutter/flutter#54226
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: desktop Running on desktop engine flutter/engine repository. See also e: labels. platform-windows Building on or for Windows specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants