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

Inspecting an exported typed dictionary while editing a script grabs the focus away from the script editor #96913

Closed
Mashmashin opened this issue Sep 12, 2024 · 3 comments · Fixed by #100932

Comments

@Mashmashin
Copy link

Tested versions

4.4.dev2

System information

Windows 11 - Godot 4.4.dev2 - Vulkan(Forward+)

Issue description

If you have typed dictionary open in the inspector (so you can edit the values), it will grab the focus away from script editor everytime it has done checking for errors.

Here's a video I am experiencing

Steps to reproduce

  1. Create a script with export variable that is any kind of typed dictionary.
  2. Attach it to a node and click the node so you can see the exported typed dictionary.
  3. In inspector, open the dictionary so the keys and values are shown in the inspector.
  4. Edit script in the script editor in any way and wait for the script editor to check for errors.
  5. The typed dictionary's "New Value" should grab the focus away from the script editor.
    This is very noticeable if you change the "text_editor/completion/idle_parse_delay" in EditorSettings to a very low value.

Minimal reproduction project (MRP)

dictionary_issue.zip

@AThousandShips AThousandShips added this to the 4.4 milestone Sep 12, 2024
@AThousandShips AThousandShips moved this from Unassessed to Not Critical in 4.x Release Blockers Sep 12, 2024
@AThousandShips AThousandShips removed this from the 4.4 milestone Sep 12, 2024
@AThousandShips AThousandShips moved this from Unassessed to Not Critical in 4.x Release Blockers Sep 12, 2024
@AThousandShips AThousandShips added this to the 4.4 milestone Sep 12, 2024
@AThousandShips
Copy link
Member

AThousandShips commented Sep 12, 2024

Haven't confirmed but should be caused by this code:

// We need to grab the focus of the property that is being changed, even if the type didn't actually changed.
// Otherwise, focus will stay on the change type button, which is not very user friendly.
if (changing_type_index == slot.index) {
callable_mp(slot.prop, &EditorProperty::grab_focus).call_deferred(0);
changing_type_index = EditorPropertyDictionaryObject::NOT_CHANGING_TYPE; // Reset to avoid grabbing focus again.
}

But can't see how it is affected specifically by typed dictionaries, but confirmed that non-typed dictionaries won't trigger this

CC @Repiteo

@Dowsley
Copy link
Contributor

Dowsley commented Sep 12, 2024

@AThousandShips I found that grab_focus skips focusing with an early return, but only for non-typed arrays. I believe it has to do with the default value that only appears for typed ones, e.g. 0 for int values.

Do you mind if I try fixing this?

@nyha-neoma
Copy link

I was about to open an issue but I've seen this one.
Also happens when saving the script containing the exposed variable, and when saving the whole project as well.

Godot_v4.4-dev3_win64_21eoP1uche.mp4

I don't know whether the proposed fix solves this issue.

@akien-mga akien-mga changed the title (4.4.dev2) Inspecting an exported typed dictionary while editing a script grabs the focus away from the script editor Inspecting an exported typed dictionary while editing a script grabs the focus away from the script editor Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Not Critical
4 participants