Skip to content

Setting current_tab of a tab container doesn't work when it's not visible or not ready #91135

Closed
@spiralhalo

Description

@spiralhalo

Tested versions

  • Reproducible in: 4.3.dev5
  • Not reproducible in: 4.2.1

System information

Godot v4.3.dev5 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 SUPER (NVIDIA; 31.0.15.3118) - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 Threads)

Issue description

This issue is two-fold (I don't know if I should make separate issues as they seem related):

  • Setting current_tab from script doesn't work when the tab container is not ready. (It works previously) For example, when setting the current_tab from an "uncle" node's _ready() that is higher up in the tree than the parent node.
  • Setting current_tab from script doesn't work in a nested tab container where the target container was not visible, when performed from a button click. select_next_available() doesn't seem to work either.

I noticed this behavior because my project which was working in Godot 4.2.1 no longer works properly in Godot 4.3.dev5 in regards to tab containers.

Setting the current tab in the editor does always seem to work on the other hand.

Current "workaround"

Instead of setting current_tab, setting the tab control's visibility directly seems to work reliably.

Steps to reproduce

Reproduction 1 (not ready)

  • Create 2 sibling nodes, the ordering is important. Attach script to the 1st node, and add a tab container with 2 distinct tabs to the 2nd node. Set the current tab to 0 in the editor inspector.
  • In the 1st node's script's _ready() function, set the tab container's current_tab to 1. It does not work, presumably because the tab container is not ready.
  • In the scene's root node, attach a script and set the tab container's current_tab to 1 in its _ready() function. It does work, presumably because the children are ready, including the tab container.

Reproduction 2 (not visible)

  • Create a nested tab container structure with 1 parent tab container and 2 child tab containers as its tabs. Then add 2 distinct tabs each to the child tab containers. Set the current tab of all tab containers to 0 in the editor inspector.
  • Add a button to the scene's root node. Attach a script in the scene's root node and connect the button's pressed() signal. In the _on_button_pressed() function, set the top tab container's current_tab to 1 then set the 2nd child tab container's current_tab to 1 in the next line.
  • Run the project, click the button once. The top tab container current_tab will change successfully, however the 2nd child's current_tab will fail to change, presumably due to it being previously/currently invisible. Click the button again, now it works because the 2nd child is now visible.

Minimal reproduction project (MRP)

This project contains both reproduction method in separate scenes. Open the scene and run them individually.

  • not_ready_reproduction.tscn for the "not ready" issue reproduction
  • not_visible_reproduction.tscn for the "not visible" issue reproduction

godot4.3.dev5_tab_container_test.zip

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions