0 votes

I am using Godot 4 Alpha 1. It should be possible to just close the ColorPicker when the user selects a color. I can see the signal but no obvious function to close the ColorPicker.

Godot version 4 Alpha1
in Engine by (54 points)

1 Answer

–1 vote

There are several ways you can go with this the easiest being to call the hide() function

Another would be to attach it a a pop-up modal or use ColorPickerButton which does the previously mentioned

by (5,020 points)

I am using ColorPickerButton and it doesn't do that. There is no method listed on ColorPickerButton to close the ColorPicker pop up directly. I have read that the user can click a cross or click outside the button (I didn't find a cross).

I double checked using a ColorPickerButton- clicking a color does not close the ColorPickerButton. get_colorpicker().hide() messes up the ColorPickerButton leaving a rectangle the size of the ColorPicker.

Created a simple scene, connected the color_changed signal and it works as intended

# ColorPickerButton.gd
func _on_ColorPickerButton_color_changed(color):
    get_popup().hide()

The default to not have the ColorPopup closed with the selection of a color is intentional as this is the preferred behavior

Your use case may differ and so may produce unpredictable results. Please share a code snippet or your exact intended outcome.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.