godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Make the code completion box a popup #7731

Open rambda opened 1 year ago

rambda commented 1 year ago

Describe the project you are working on

image One-line-height custom property editor with auto completion.

The test_tag::node_path is an EditorProperty for auto-completing NodePath of nodes within singletons, see https://github.com/godotengine/godot-proposals/issues/7704 if interested.

Describe the problem or limitation you are having in your project

image if using a one-line-height CodeEdit, auto completion box is not visible since it's not a pop-up.

To solve this, I place a LineEdit there for the look. And I use a CodeEdit for auto completion. I put a CodeEdit on CanvasLayer to make the CodeEdit floating to accomplish a similar feeling. This is hacky.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Make the code completion box a pop-up. So that:

  1. LineEdit can utilize it.
  2. Or we can have LineCodeEdit
  3. Or I can still use one-line-height CodeEdit.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

No. I've implemented it back in 3.x. I will require tons of code and Control nodes. And I had to do it in a very hacky way. I remember I had to simulate InputEvent for some reason. And it's impossible to have the syntax highlight in the completion items without being too hacky.

Is there a reason why this should be core and not an add-on in the asset library?

It's core. I think it's very useful. Another example, VS Code: image

Calinou commented 1 year ago

One issue with making it a popup is making sure it doesn't get keyboard focus when it appears. Also, it would no longer be able to appear when in exclusive fullscreen mode.