Skip to content

Find parent TabContainer in a more robust manner (for 4.7.2 compatibility) - #45

Open
lfod1997 wants to merge 2 commits into
gilzoide:mainfrom
lfod1997:fix/4.7.2-internal-node-structure-change
Open

lfod1997 wants to merge 2 commits into
gilzoide:mainfrom
lfod1997:fix/4.7.2-internal-node-structure-change

Conversation

@lfod1997

@lfod1997 lfod1997 commented Oct 6, 2026 •

Copy link
Copy Markdown

Contribution

Fixes #44 .

Breaks nothing.

Tested Under

v4.7.2.stable.official [ed1daf0bf]

Details

Cause of Issue

In 4.7 the dragged TabBar is wrapped in HBoxContainer:

Godot 4.7 tab bar node structure

Drop data points to "@​TabBar@​4"; in the original impl:

if from_node is TabBar:
	from_node = from_node.get_parent()

from_node becomes "@​HBoxContainer@​2", which is still not the TabContainer we want, breaking a later call:

var moved_tab = from_node.get_tab_control(tab_index)

("Invalid call. Nonexistent function 'get_tab_control' in base 'HBoxContainer'.")

Solution

I suggest finding its first TabContainer ancestor in a loop:

while from_node is not TabContainer:
	from_node = from_node.get_parent()

It:

  1. Fixes our problem
  2. Does not break the "if not me, must be my immediate parent" semantics in earlier Godot versions
  3. Somewhat future-proof

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breaks in 4.7.2

1 participant