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

Closing PopupMenu of OptionButton via code on window resize error : '_sub_window_update: Condition "index == -1" is true' #100613

Open
TinyTakinTeller opened this issue Dec 19, 2024 · 0 comments

Comments

@TinyTakinTeller
Copy link

TinyTakinTeller commented Dec 19, 2024

Tested versions

v4.3.stable.official [77dcf97]

System information

Windows 11 - Godot 4.3 - Compatibility

Issue description

What is proper way to close popup menu of OptionButton?

There is self.show_popup() to show it, but I do not see a close option. Am I missing something?

Trying to do (on "size_changed" signal)

self.get_popup().visible = false

hides it but logs an error

E 0:00:07:0991   _sub_window_update: Condition "index == -1" is true.
  <C++ Source>   scene/main/viewport.cpp:310 @ _sub_window_update()

Note that docs state that using visible property should be okay?

PopupMenu get_popup() const

Returns the PopupMenu contained in this button.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their Window.visible property.

Steps to reproduce

  1. Create new project
  2. Create new main scene (Control)
  3. Add OptionButton as child with at least 1 option
  4. Attach script to main scene
extends Control

@onready var option_button: OptionButton = $OptionButton

func _ready() -> void:
	get_tree().get_root().connect("size_changed", _on_root_size_changed)
	
func _on_root_size_changed() -> void:
	option_button.get_popup().visible = false
  1. Start the project
  2. Click on option button to open popup
  3. Resize the window (trigger signal)
  4. Read error in console

Minimal reproduction project (MRP)

new-game-project.zip

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

2 participants