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

Editor ignoring Ctrl + Shortcuts after losing focus while holding Right Alt #28511

Closed
mostlysoftware opened this issue Apr 29, 2019 · 48 comments · Fixed by #71730
Closed

Editor ignoring Ctrl + Shortcuts after losing focus while holding Right Alt #28511

mostlysoftware opened this issue Apr 29, 2019 · 48 comments · Fixed by #71730

Comments

@mostlysoftware
Copy link

Godot version:
3.1.1 Stable Win 64

OS/device including version:
Windows 10 Version 10.0.17763 Build 17763

Issue description:
Godot will randomly stop accepting any shortcut that uses the CTRL key. For example, pressing "CTRL+S" will switch to the scale tool instead of saving. Restarting Godot will fix it for either 5 seconds or 5 minutes.

Pressing control does cause the ruler to change, so it knows the key is being pressed. It's just ignoring it in combination with other keys.

I've tried updating windows, nuking my app data, upgrading godot, running as admin, compatibility settings, a different computer, sticky key settings, and whatever else I could think of.

Steps to reproduce:
I've been pulling my hair out trying to figure out what causes it. Sometimes it seems to happen after a parsing error. Sometimes it happens on its own. I can reproduce it on both of my laptops (surface go and hp spectre x360 15), but not on command. It has a mind of its own.

Minimal reproduction project:
Happens on any type of project. I've managed to trigger this on a brand new project with only 1 node and 1 script.

@groud
Copy link
Member

groud commented Apr 29, 2019

Likely fixed by #28465. Could you try with latest master ?

@akien-mga
Copy link
Member

akien-mga commented Apr 29, 2019

@groud That should not be related, #28465 fixed a regression in the master branch which was not cherry-picked to the 3.1 branch.

@akien-mga akien-mga added this to the 3.2 milestone Apr 29, 2019
@groud
Copy link
Member

groud commented Apr 29, 2019

@akien-mga ah indeed.
It's surprising, it looks exactly like the problem @mrcdk described on IRC, just before fixing it with #28465. Probably different sources though.

@mostlysoftware
Copy link
Author

I can confirm, it's not the same issue as #28465. Pressing control doesn't fix the problem, and pressing S doesn't save. The only way to fix it is to completely exit Godot, but that only fixes it for a few minutes at most.

@amisner2k
Copy link

Can confirm as well. I'm running the latest 3.1.1.stable.
Pressing CTRL key causes ruler to change and when I'm in the the Script editor view, pressing CTRL puts underlines over all "navigate to" symbols, where normally the underline only appears when you mouse over a "navigate to" symbol while CTRL key is pressed.

When it's in this borked state, I noticed that CTRL+C will actually clear highlighted text in the editor. Basically you can't trust any CTRL+ key combo after the bug rears its head.

Restarting the editor fixes the issue temporarily, as @mostlysoftware describes.

@Calinou
Copy link
Member

Calinou commented Sep 12, 2019

@amisner2k Which operating system are you on? This bug could be OS-specific.

@amisner2k
Copy link

@amisner2k Which operating system are you on? This bug could be OS-specific.

Good call. I'm on Windows 10.

@amisner2k
Copy link

This is really bizarre, has no one else reported this or do not very many people use the keyboard shortcuts involving the CTRL key? @Calinou , were you able to reproduce this?

@Calinou
Copy link
Member

Calinou commented Sep 13, 2019

@amisner2k I haven't been able to reproduce this on Linux.

Maybe this is caused by accumulated input (similar to #27104)? To verify this, download the Godot source code, change the true to false on the line linked below then recompile the editor:

Input::get_singleton()->set_use_accumulated_input(true);

See Compiling for Windows for instructions on how to compile Godot from source.

@amisner2k
Copy link

Ok, that is a good idea and something I'd like to do sometime in the near future. However, if someone on here already has 3.1.1.stable compiled and working on their Windows machine, then It'd be awesome if they could try flipping that true to false to see if it'd work real quick. Otherwise, I'll try it out when I get around to compiling Godot for myself. Either way, thank you @Calinou for that lead.

@amisner2k
Copy link

amisner2k commented Sep 17, 2019

Just wanted to add that I did something I'm guessing others have done to work around this issue: remap some of the shortcuts to not use the Ctrl key.

However, when I did that, I noticed that it also seemed to fix the issue altogether. Before when the bug occurred, any shortcut key involving Ctrl would be mixed up. Ctrl+C would end up clearing an entire line in the Script Text editor for example, it was crazy. After I remapped Ctrl+S and Ctrl+Shift+S to simply be Alt+S and Alt+Shift+S, the Ctrl key would work again in the Script Text editor (I didn't have to restart Godot or anything). Very weird but for now, the workarounds aren't bad at all.

I still look forward to building Godot from source in the future and maybe this bug, if it still exists, will be my first adventure. This engine is quite simply...amazing.

@amisner2k
Copy link

Ok, so I discovered that the bug occurs consistently and the thing that triggers it is Alt+Tabbing away from Godot. So repro is:

  1. Have Godot open
  2. Alt+Tab to another window
  3. Go back to Godot window (via Alt+Tab or otherwise, doesn't matter)
  4. Ctrl+ shortcuts are messed up.

So something is going on with the Alt+Tab key combination in Godot. If I find time to build Godot's source myself, I'll dig further, but hopefully someone else more experienced can take up the mantle and find the issue quicker than I can.

@amisner2k
Copy link

Another update:
I noticed that if you just press the Alt key, the shortcut keys work again. No need to restart the editor.

@cur33
Copy link

cur33 commented Dec 1, 2019

This problem has really been bugging me, and I hadn't even considered that Alt+Tab might be the issue. I use that a lot, so it's no wonder than I kept running into this bug. Great insight and workaround, @amisner2k !

I tested the suggestion from @Calinou for changing that value from true to false and then recompiling Godot, and unfortunately the issue was still present. The workaround still worked, though. But we'll have to look elsewhere to actually fix it.

@amisner2k
Copy link

Thank you for taking the time to verify that @cur33, at least we can rule that out as a possible solution. And yeah, fortunately the workaround is quick and easy. :)

@akien-mga akien-mga modified the milestones: 3.2, 4.0 Jan 15, 2020
@cur33
Copy link

cur33 commented Jan 30, 2020

@amisner2k and others, the plot thickens: I've noticed that this issue only occurs when I use the right Alt button on my keyboard, and never the left. If I Alt-Tab away using with the left Alt (not something I usually do, which is why I haven't noticed til now), and then return to Godot, Ctrl+ shortcuts still work as expected. However, if I Alt-Tab away with the right Alt then return to Godot, I have to use the workaround of pressing right Alt (pressing left Alt does not fix it) before the Ctrl+ shortcuts work again.

For context, I'm on Windows 10, and confirmed this behavior on both 3.1.1 Stable (Mono) and 3.2 Stable (Mono); I just upgraded today.

I'd love to tackle this issue myself, but I don't really have the time right now and I've never contributed to Godot before so I'm not all that familiar with the codebase (although I do have C++ experience, so that helps). But since it's relatively low priority, then I'll definitely see if I can shed any light on this if the issue is still open when I have more time.

@ghost
Copy link

ghost commented May 15, 2020

I also am having this in the latest 3.2 with win 10. Doesn't happen often, so I prematurely closed my issue #35844.

I recently had it happen when tabbing back into the editor. What I noticed was the script editor file menu was reduced to only File. Tabbing in and out again made the other elements return, and the shortcuts returned.

Not 100% though if it's the same issue, or if another exists regarding gui not being completely restored.

For those that can reliably reproduce it, you might see if other shortcuts are affected from the same areas as the CTRL+ ones you are using.

@DataPlusProgram
Copy link

I get an issue like this a lot.

Ctrl+C cuts text.
Ctrl+X does nothing.
Ctrl+S does nothing.

Currently I'm using 3.3.3 stable but I've had it across multiple versions.
I don't know the cause of it and it seems random to me.

This happens to me many times a day and I'm always restarting Godot because of it.

If anyone wants me to set any breakpoints or test out other hotkeys I can.

@duianto
Copy link

duianto commented Nov 1, 2021

@cur33 is correct. #28511 (comment)
This is related to the Right Alt key

The Ctrl + {key} key bindings break when
switching to another application with Right Alt + Tab
And switching back to Godot with either the left or right Alt keys and Tab,
or by mouse clicking on the Godot icon in the taskbar.

The Ctrl keys do not break when switching to another app with: Left Alt + Tab

Workaround

Press the Right Alt key once, to restore the Ctrl key bindings.

Reproduction steps

  • Start Godot
  • Create a new or open an existing project
  • Add a node: 3D Scene
  • Move the node in the 3d view
  • Switch to another application: Right Alt + Tab
  • Switch back to Godot with any method:
    Right (or left) Alt + Tab
    or by mouse clicking on Godot in the taskbar.

Observed

Most of the Ctrl + {key} key bindings have stopped working.
For example: Ctrl + z and Ctrl + s

These work as expected:
ctrl + 1 to ctrl + 4 splits the 3d view

But these don't work the same as when the Ctrl key bindings are not broken.

The following key bindings change the colors of the 3d view menu buttons,
but nothing changes visually in the 3d view.
ctrl + q the select mode arrow icon changes from blue to white
ctrl + w the move mode icon changes color to blue
ctrl + e the rotate mode icon changes color to blue, the previous icon remains blue
ctrl + r the scale mode icon changes color to blue, the previous icons remain blue
ctrl + t the use local space changes icon color to blue, the previous icons remain blue
ctrl + y the use snap icon changes color to blue, the previous icons remain blue

ctrl + o centers the origin in the 3d view
Ctrl + f centers the Spatial node in the 3d view
(the same thing happens when just o and f are pressed)

ctrl + k shows Keying is disabled (no key inserted).,
in the bottom left corner of the 3d view.
(k does the same thing)
The message only appears once after moving the spatial node.

Expected

The Ctrl + {key} key bindings should not stop working,
when switching to another application with the Right Alt key.

Notes

It isn't limited to the 3D Scene node, it happens with any node.

System

Godot

Windows 21H1

This is reproducible with a clean setup.
By removing the directory: C:\Users\username\AppData\Roaming\Godot.

@DataPlusProgram
Copy link

That information clears things up for me.

If you are holding Right Alt and the Godot windows loses focus then this glitch happens.

What's probably happening is that Right Alt doesn't get released when the Godot window loses focus so you have to press it again stop Godot viewing it as being constantly held.

I have a program on my computer that opens a dialogue window on Right Alt + Space so that is probably why I was getting this a lot.

Knowing that pressing right alt fixes this saves me a ton of time.

@KoBeWi
Copy link
Member

KoBeWi commented May 31, 2022

Can still reproduce in 532e253 using the Right Alt, but I never use this key so the issue never triggered for me accidentally.

@akien-mga akien-mga changed the title Editor randomly ignoring CTRL + Shortcuts Editor ignoring Ctrl + Shortcuts after switching windows with Right Alt + Tab Jan 20, 2023
@DataPlusProgram
Copy link

I am using windows with a custom keybinding that opens a window for Right Alt + Tab

All that is needed to replicate the bug is to hold Right Alt and cause the Godot window to lose focus. By either clicking on another monitor or outside the window boundary if it's not fullscreen.

My keyboard layout is standard English QWERTY

@duianto
Copy link

duianto commented Jan 20, 2023

v3.5.1.stable.official [6fed1ff]
v3.5.2.rc2.official [1a2bf3e]
v4.0.beta13.official [caacade]
Windows 10 22H2
Keyboard layout: US QWERTY

@akien-mga
Copy link
Member

akien-mga commented Jan 20, 2023

All that is needed to replicate the bug is to hold Right Alt and cause the Godot window to lose focus. By either clicking on another monitor or outside the window boundary if it's not fullscreen.

Thanks, that's the most concise reproducer and I was able to reproduce the bug too on Linux by doing this. Also with US QWERTY. So it's not system nor keyboard layout specific.

EDIT: So I was misled, my Right Alt is configured as the Compose key on my system, which acts like a dead key to form advanced characters. That's why it eats up the next two inputs, it's unrelated to holding it / losing focus and thus not this bug at all. So I'm back to thinking this is probably Windows specific.

Invalid attempt at reproducing on Linux

Here's how I reproduce it reliably:

  • Open Godot in windowed mode, focused.
  • Hold Right Alt.
  • Lose focus while keeping Right Alt held (e.g. by pressing Left Alt + Tab, or clicking outside the Godot window).
  • Release Right Alt while Godot is unfocused.
  • Click Godot in the task bar to show it again and regain focus.
  • Ctrl + S doesn't work the first two times I press it. The third time it works (for me on KDE Plasma).

@akien-mga akien-mga changed the title Editor ignoring Ctrl + Shortcuts after switching windows with Right Alt + Tab Editor ignoring Ctrl + Shortcuts after losing focus while holding Right Alt Jan 20, 2023
@duianto
Copy link

duianto commented Jan 20, 2023

In Windows 10, after unfocusing Godot with right alt, and focusing it again.
The first ctrl + s highlights the Scale tool (it gets a blue color) above the top left corner of the viewport.
Its shortcut is listed as (S), so it might be interpreting ctrl + s as a s key press without a modifier.

Nothing changes when one continues to press ctrl + s (tested 10 times)

Pressing and releasing right alt, once, restores ctrl + s to show the Save Scene As... window,
in a project with just an unsaved Node2D

@DataPlusProgram
Copy link

For me Ctrl + S will never work no matter how many times it's pressed. It can only be fixed by pressing Right Alt again.
Also of note when in this state Ctrl + C appears to act like cut instead of copy

@akien-mga
Copy link
Member

Edited my previous post, my test was wrong on Linux, the symptoms I saw were just due to using the Right Alt key as Compose key. If I remove the config for it to be the Compose key, I can't reproduce this bug.

@duianto
Copy link

duianto commented Jan 20, 2023

Also of note when in this state Ctrl + C appears to act like cut instead of copy

How are you testing that?

For me in 3.5.1, 3.5.2.rc2, and 4.0.beta13, when the right alt bug is active,
then nothing happens in the Script Editor, when ctrl is followed by: z or x or c or v

@DataPlusProgram
Copy link

For me Ctrl + C and Ctrl + X still work. where Ctrl + C is now cut and Ctrl + X just deletes selected text

@reduz
Copy link
Member

reduz commented Jan 20, 2023

@duianto In your report, you mention that you are switching to another application with right alt-tab, but on Windows 10 with US Qwerty, this is simply not possible (Only left-alt tab is supported). Do you have something else installed that is allowing this?

I just tried to no avail on same setup (Windows 10 and US Qwerty) and I can't reproduce the issue in any way, nor I can't switch windows with right-alt + tab.

@duianto
Copy link

duianto commented Jan 20, 2023

For me, right alt + tab works the same as left alt + tab throughout Windows 10,
in that, it switches to the previously active application.

Holding down one of the alt keys and pressing and releasing tab, shows the task switcher,
which lists all open applications.

Pressing tab switches to the next application, shift + tab switches to the previous application.

Releasing the alt key, focuses the selected application.

Could it be a physical keyboard issue?, the right alt key on my keyboard says Alt Gr

@reduz
Copy link
Member

reduz commented Jan 20, 2023

Nevermind I can reproduce the issue now, it failed because I am using Synergy. Connecting a keyboard directly works.

@reduz
Copy link
Member

reduz commented Jan 20, 2023

Fix incoming ⬆️

@DataPlusProgram
Copy link

I have complied with the gr_mem = false; flag set in 3.x a on Windows and can confirm it fixes the issues for me.

@duianto
Copy link

duianto commented Jan 20, 2023

Confirmed in: v4.0.beta.custom_build [a5ccff194]
The ctrl shortcuts continue to work after right alt was pressed when Godot lost focus.

@akien-mga akien-mga modified the milestones: 4.x, 3.6 Jan 21, 2023
Streq pushed a commit to Streq/godot that referenced this issue Feb 9, 2023
akien-mga pushed a commit to akien-mga/godot that referenced this issue Mar 6, 2023
akien-mga pushed a commit to akien-mga/godot that referenced this issue Mar 6, 2023
Stary2001 pushed a commit to Stary2001/godot that referenced this issue Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.