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

Renaming file in file explorer not working on lost focus #78789

Closed
tokengamedev opened this issue Jun 28, 2023 · 8 comments
Closed

Renaming file in file explorer not working on lost focus #78789

tokengamedev opened this issue Jun 28, 2023 · 8 comments

Comments

@tokengamedev
Copy link

Godot version

4.1.rc.1

System information

Windows 11

Issue description

When you try to rename a file in file explorer, if the focus is lost from the file explorer it does not work.
Although, it works when the file explorer is in focus.

renaming.on.lost.focus.not.working.mp4

All other functionalities like "Duplicate..." works even if the focus is not there.

Note: Also the name of the Rename menu should remove three dots after name as it does not invoke a dialog anymore, if we are following standards.

Steps to reproduce

Select a file in the file explorer and click on the text editor to ensure focus is lost (highlighted color border should not be there on file explorer)
Now right click the file in file explorer and click "Rename..."

Nothing happens

Minimal reproduction project

N.A

@KoBeWi
Copy link
Member

KoBeWi commented Jun 28, 2023

The is a check for focus when renaming. It should probably check visibility:

if (tree->has_focus()) {
// Edit node in Tree.
tree->edit_selected(true);
if (to_rename.is_file) {
String name = to_rename.path.get_file();
tree->set_editor_selection(0, name.rfind("."));
} else {
String name = to_rename.path.left(-1).get_file(); // Removes the "/" suffix for folders.
tree->set_editor_selection(0, name.length());
}
} else if (files->has_focus()) {
files->edit_selected();
}

Although I think it prevents renaming files when another editor is focused, so maybe it should stay this way.

Though the fact that the dock is not focused when context menu opens is a bug.

@Sauermann
Copy link
Contributor

Possibly this might get solved by #75062

@tokengamedev
Copy link
Author

IMO removing context menu when focus is not there is really bad, since it will impact other existing functionalities that work.

Although #75062 will resolve the main issue, also consider changing the name in the menu itself.

@quinnyo
Copy link
Contributor

quinnyo commented Jul 10, 2023

Renaming should work without the dock having/retaining keyboard focus.

Note that the scene tree dock doesn't have this issue. It does exhibit an odd focusing behaviour, however. When you activate "Rename..." in a Node's context menu, the scene tree dock grabs keyboard focus, presumably to facilitate typing the new name. Obviously the keyboard events must be captured somehow, but the dock then retains KB focus after the interaction ends. Renaming is the only context menu action that does this.

Though the fact that the dock is not focused when context menu opens is a bug.

I can't speak for the intended behaviour, but I thought it was by design that KB focus is not given to the docks unless absolutely necessary, so as to not interfere with the main editor. For example, starting in the script editor, you can right click on a property/node/file, copy its name/path and then paste it in the script (using the keyboard) without having to manually move focus back to the script editor.

The only Control that gets KB focus when you open a context menu (that I can find) is TextEdit/LineEdit, which is a fairly common pattern in desktop GUI applications.

@daveTheOldCoder
Copy link

daveTheOldCoder commented Aug 17, 2023

I'm just confirming that this issue still exists in v4.2.dev3.official [013e8e3] on Linux.

@Sauermann
Copy link
Contributor

This seems to be fixed in v4.2.dev5.official [e3e2528]

@KoBeWi
Copy link
Member

KoBeWi commented Sep 29, 2023

Right, it was fixed by #80440 Right-clicking a file focuses the dock now.

@servel333
Copy link

Why not change it so that a right click in this panel puts the focus on this panel?

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

No branches or pull requests

6 participants