Skip to content

Focus Script Editor text on dock focus and click - #123564

Open
kitbdev wants to merge 1 commit into
godotengine:masterfrom
kitbdev:focus-scripteditor-on-tab-click
Open

kitbdev wants to merge 1 commit into
godotengine:masterfrom
kitbdev:focus-scripteditor-on-tab-click

Conversation

@kitbdev

@kitbdev kitbdev commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

This makes many actions focus on the Script Editor/Shader Editor text. Including clicking on the Script / Shader Editor tab, using the shortcut (including when its already open), using the Editor Dock menu option, restoring after floating, and using EditorInterface.set_main_screen_editor("Script").
Also applies when they are floating.
These either match 4.7.2 behavior or shouldn't cause any issues.

Additional information

Adds a callback when a dock is focused (unexposed). The Script Editor uses this to move the focus to its CodeEdit. Also applies to Shader Editor.
When a tab is clicked it now calls focus_dock. I don't think this has an effect in most cases since the tab would already be focused.

Also moved ScriptEditor::update_layout since it was near the unrelated ScriptEditorQuickOpen methods.

@kitbdev kitbdev added this to the 4.8 milestone Sep 16, 2026
@kitbdev
kitbdev requested review from a team as code owners September 16, 2026 20:50
@kitbdev
kitbdev force-pushed the focus-scripteditor-on-tab-click branch from cdde67e to b4308be Compare September 22, 2026 19:41
@kitbdev

kitbdev commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Now uses force_focus_dock.
Fixes an issue where the ScriptEditor wasn't being switched to when on the game/asset store tabs for various actions.

@KoBeWi

KoBeWi commented Sep 23, 2026

Copy link
Copy Markdown
Member

Adds a callback when a dock is focused

Isn't NOTIFICATION_VISIBLITY_CHANGED enough? That's the intended way to perform actions when a dock is focused (made visible).

@kitbdev

kitbdev commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Isn't NOTIFICATION_VISIBLITY_CHANGED enough? That's the intended way to perform actions when a dock is focused (made visible).

It's not enough, especially for shader editor which needs to be able to open without taking any focus when clicking on nodes.
Also it should be able to focus even when it is already open.

@kitbdev
kitbdev force-pushed the focus-scripteditor-on-tab-click branch from b4308be to 21432f8 Compare September 26, 2026 17:43
@kitbdev
kitbdev requested a review from a team as a code owner September 26, 2026 17:43
@kitbdev
kitbdev force-pushed the focus-scripteditor-on-tab-click branch from 21432f8 to 901e28c Compare September 26, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[4.8 dev4 regression] Using Open Script Editor shortcut does not focus the text area of the script editor

2 participants