imgui: OSX backend: Modifier Keys broken, including Command + C/V/Z

Version/Branch of Dear ImGui:

Version: 1.83 Branch: master (98876b4dc233d4b2cea22cc9a6d3e49a6ac2d59d)

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_osx, imgui_impl_opengl2 Compiler: Apple Clang Operating System: Screen Shot 2021-06-21 at 11 12 50 AM

My Issue/Question: Copy/Paste broken? The issue I am seeing is using Command+C and Command+V. Instead of copying to the clipboard and pasting from the clipboard, a C and a V are inserted into the text.

I am convince this is related to ResetKeys() in imgui_impl_osx.mm

Screenshots/Video Command C/V/Z busted here.

https://user-images.githubusercontent.com/42980705/122788006-e20d4000-d283-11eb-835b-6f2e130586a0.mov

Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261) Screen Shot 2021-06-21 at 11 18 49 AM

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

The fix (https://github.com/ocornut/imgui/commit/0b8a2470743f89d19ab2d5920606434b604b529e) was merged. Funny story. Turns out we had KeyCtrl and KeySuper mixed up in a shortcut check. But it did work when code was first added, because older version of sample swapped these keys to get PC-like shortcuts on a Mac. Eventually that change was lost and this function broke and nobody noticed for a long while since this backend is hardly used. It really is better idea to use SDL/GLFW as @ocornut said. 👍🏻

This is a backend issue so there’s little point is digging into InputText code. If you can confirm the key state are wrong when displayed in the demo window, we have to look at the backend.

Closing as fixed, Richard let us know if you find other problems this is backend.

I think the issue is strictly at the imgui_impl_osx.mm level and you can look at the inputs provided by the backend in Demo>Inputs, Navigation & Focus>Keyboard State

6d5388448 added the modifiers clear which triggered the bug, but it’s merely consistent with clearing the keys. That backend is a severe mess (partly because of a limitation in the IO system, which will be lifted by io_queue work), generally we recommend people using the SDL or GLFW backend on OSX.

In earlier e54b61aa (second to initial commit)

  • in ImGui_ImplOSX_HandleEvent() the “// We must reset in case we’re pressing a sequence of special keys while keeping the command pressed” block was modified by, either version are equally bizarre.
  • NSEventTypeFlagsChanged handling also calls resetKeys()

Someone would need to do a deep dive in figuring out why the code was designed this way with the resetKeys() calls.