godotengine / godotengine/godot-cpp

`Control::gui_input` is not exposed

Open
#1,426 5 comments 0 reactions 0 assignees View on GitHub
discussion enhancement topic:gdextension
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### Godot version

4.2.1

### godot-cpp version

4.2

### System information

Windows 11

### Issue description

`Control::gui_input` is not exposed and `Control::_gui_input` is not its GDExtension counterpart, not allowing sending events to other `Control` nodes with specific behaviours.

The use case is trying to reproduce the behaviour of Godot visual shader editor add node dialogue, where you can filter the options with a `LineEdit` on focus, while also being able to go up and down with the keyboard among the filtered member options in the `Tree`.

![immagine](https://github.com/godotengine/godot-cpp/assets/62719360/60713015-ff8f-4f68-be12-0848dca534ea)

This is the code you want to be able to call to sent events to `Tree *member` (from https://github.com/godotengine/godot/blob/master/editor/plugins/visual_shader_editor_plugin.cpp)...

```cpp
void VisualShaderEditor::_sbox_input(const Ref &p_ie) {
Ref ie = p_ie;
if (ie.is_valid() && (ie->get_keycode() == Key::UP || ie->get_keycode() == Key::DOWN || ie->get_keycode() == Key::ENTER || ie->get_keycode() == Key::KP_ENTER)) {
members->gui_input(ie);
node_filter->accept_event();
}
}
```
...but changing `members->gui_input(ie);` to `members->_gui_input(ie);` has not the same results, as `_gui_input()` in GDExtension has only overriding purposes as of now.

I'll quote a comment by @Zylann from https://github.com/Zylann/godot_voxel/blob/master/editor/graph/voxel_graph_node_dialog.cpp as it seems he found the same issue:

> // TODO GDX: `Control::gui_input()` is not exposed to GDExtension, can't forward events.
// This is what `VisualShaderEditor::_sbox_input` does.
// `_gui_input` is exposed, but that's only for user implementation, not for calling directly...
// Also `gui_input` is a name already taken in GDScript, so if it gets exposed some day, it will need a
// different name.
//
// _tree->gui_input(key_event);

Will it be exposed correctly in the future?

### Steps to reproduce

As explained in the description, try to use `_gui_input()` on any `Control` child class.

### Minimal reproduction project

No minimal reproduction project needed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.