How to close the Colorpicker on ColorPickerbutton once the user selects a color?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cloa513

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.

:bust_in_silhouette: Reply From: Wakatta

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

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).

cloa513 | 2022-03-26 07:14

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.

cloa513 | 2022-04-13 12:16

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

func _on_ColorPickerButton_color_changed(color):

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.

Wakatta | 2022-04-13 17:08