godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.17k stars 21.2k forks source link

Copy and paste shortcuts don't work in Visual Script editor #41156

Closed KoBeWi closed 3 years ago

KoBeWi commented 4 years ago

Godot version:

3.2.3 rc3

Issue description:

When in Visual Script editor, you can't use Copy and Paste shortcuts. You need to select them from the Edit menu. All other shortcuts seem to work (including Cut and the unlisted Duplicate shortcut...)

Kartik1397 commented 4 years ago

Can I work on this issue?

KoBeWi commented 4 years ago

Yeah, no need to ask btw.

KoBeWi commented 4 years ago

Sorry it wasn't, it's about Visual Script not Visual Shader.

Kartik1397 commented 4 years ago

Are KEY_C and KEY_V handled specially? because if I change KEY_C to KEY_I and KEY_V to KEY_K it's start working properly. Also if I change focus to some other panel then all shortcut are working as expected.

EricEzaM commented 4 years ago

I have not looked into this in detail but it sounds very much like it is related to #39039 and the issues that it mentions.

The ctrl c and ctrl V commands are just being 'stolen' by another editor plugin, like the script editor or scene tree dock.

The way shortcuts are handled in the editor and GUI in general needs a big rethink - something I have been pondering on for quite some time but have no solution yet.

EricEzaM commented 4 years ago

Ok, actually the problem is pretty simple.

Graph edit has it's own keybindings set internally which cannot be changed.

https://github.com/godotengine/godot/blob/6f4384f2063dc892b751eda750e120d72119644a/scene/gui/graph_edit.cpp#L1036-L1056

Because this happens on _gui_input() and the event is marked as handled, the event does not propagate any more. As you can see, GraphEdit emit's signals showing that dupe, copy, paste and delete was requested. However, in VisualScriptEditor copy and paste signals are never connected to - only duplicate and delete are.

https://github.com/godotengine/godot/blob/6f4384f2063dc892b751eda750e120d72119644a/modules/visual_script/visual_script_editor.cpp#L4767-L4781

So to fix the issue the signals just need to be connected. It is very weird to have these baked-in shortcuts, and they cause many issue like this I think.