It is possible to disable a color picker as other button or text edit?

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

It is possible to disable a colorpicker as other button or text edit ?

You mean $ColorPicker.visible = false?

Not really, I want to keep it visible like as button who can be enabled/disabled.

Yes, kinda, with some work:

extends ColorPicker


@export var disabled:bool = false:
	set(value):
		disabled = value
		_update_disabled()


func _update_disabled() -> void:
	# Wait for the color picker to be ready
	if not is_node_ready():
		await ready

	# Get all the Control children of the color picker
	var children = find_children("*", "Control", true, false)
	# For each child
	for child:Control in children:
		# block or unblock the signals
		child.set_block_signals(disabled)
		# if it has a set_disabled method
		if child.has_method('set_disabled'):
			# enable or disable it
			child.set_disabled(disabled)
		# if it has a set_editable method
		if child.has_method('set_editable'):
			# enable or disable it (disabled = not editable)
			child.set_editable(not disabled)

Thank’s a lot !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.