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

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

Closed
KoBeWi opened this issue Aug 9, 2020 · 8 comments · Fixed by #54564
Closed

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

KoBeWi opened this issue Aug 9, 2020 · 8 comments · Fixed by #54564

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Aug 9, 2020

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
Copy link

Can I work on this issue?

@KoBeWi
Copy link
Member Author

KoBeWi commented Sep 3, 2020

Yeah, no need to ask btw.

@KoBeWi KoBeWi changed the title Copy and paste shortcuts don't work in Visual Shader editor Copy and paste shortcuts don't work in Visual Script editor Sep 3, 2020
@KoBeWi
Copy link
Member Author

KoBeWi commented Sep 3, 2020

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

@Kartik1397
Copy link

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
Copy link
Contributor

EricEzaM commented Sep 15, 2020

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
Copy link
Contributor

EricEzaM commented Sep 16, 2020

Ok, actually the problem is pretty simple.

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

godot/scene/gui/graph_edit.cpp

Lines 1036 to 1056 in 6f4384f

if (k.is_valid()) {
if (k->get_keycode() == KEY_D && k->is_pressed() && k->get_command()) {
emit_signal("duplicate_nodes_request");
accept_event();
}
if (k->get_keycode() == KEY_C && k->is_pressed() && k->get_command()) {
emit_signal("copy_nodes_request");
accept_event();
}
if (k->get_keycode() == KEY_V && k->is_pressed() && k->get_command()) {
emit_signal("paste_nodes_request");
accept_event();
}
if (k->get_keycode() == KEY_DELETE && k->is_pressed()) {
emit_signal("delete_nodes_request");
accept_event();
}
}

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.

/// Actual Graph ///
graph = memnew(GraphEdit);
add_child(graph);
graph->set_v_size_flags(Control::SIZE_EXPAND_FILL);
graph->set_anchors_and_margins_preset(Control::PRESET_WIDE);
graph->connect("node_selected", callable_mp(this, &VisualScriptEditor::_node_selected));
graph->connect("_begin_node_move", callable_mp(this, &VisualScriptEditor::_begin_node_move));
graph->connect("_end_node_move", callable_mp(this, &VisualScriptEditor::_end_node_move));
graph->connect("delete_nodes_request", callable_mp(this, &VisualScriptEditor::_on_nodes_delete));
graph->connect("duplicate_nodes_request", callable_mp(this, &VisualScriptEditor::_on_nodes_duplicate));
graph->connect("gui_input", callable_mp(this, &VisualScriptEditor::_graph_gui_input));
graph->set_drag_forwarding(this);
graph->hide();
graph->connect("scroll_offset_changed", callable_mp(this, &VisualScriptEditor::_graph_ofs_changed));

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.

@matthew-j-wolf
Copy link

Why does it say closed. It still works in 4.4

@KoBeWi
Copy link
Member Author

KoBeWi commented Jan 16, 2025

It was fixed by #54564
Do you mean the bug still exists?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment