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

Editor inspector not updated on changing properties which use LineEdit for editing #43238

Open
Xrayez opened this issue Oct 31, 2020 · 4 comments · Fixed by #44326
Open

Editor inspector not updated on changing properties which use LineEdit for editing #43238

Xrayez opened this issue Oct 31, 2020 · 4 comments · Fixed by #44326

Comments

@Xrayez
Copy link
Contributor

Xrayez commented Oct 31, 2020

Godot version:
3.2.3.stable

OS/device including version:
Windows 10.

Issue description:
The property_list_changed_notify() doesn't update the editor inspector if the property's value is String.

property_list_changed_notify_string_bug

I've stumbled upon this while working on goostengine/goost#30, so the same issue is also reproducible on the C++ side with the _change_notify().

This seems to work for other types for the "type" property.

Reverting the type_string property back to default value forces to update the inspector eventually. Switching the arrows (resource history) also works to force update the inspector that way.

This sounds like a bug to me, I don't see why it wouldn't work in this case.

Steps to reproduce:

tool
extends Node2D

# This works:
export(int) var type = TYPE_STRING setget set_type

# This doesn't work:
export(String) var type_string setget set_type_string

var value

# This works:
func set_type(p_type):
	type = p_type
	property_list_changed_notify()
	# The property editor for 'value' is successfully instantiated for this type.

# This doesn't work:
func set_type_string(p_type_string):
	type_string = p_type_string
	match type_string:
		"bool":
			print("Set type via string: bool")
			type = TYPE_BOOL
		"Vector2":
			print("Set type via string: Vector2")
			type = TYPE_VECTOR2
	property_list_changed_notify()
	# The property editor is not replaced with a new type.
	# Expected to update the property of 'value' in the inspector by now.


# The `value`s type is changed dynamically here.
func _get_property_list():
	return [
		{
			"type": type,
			"name": "value"
		}
	]

Minimal reproduction project:
property_list_changed_dynamic_string.zip

@akien-mga
Copy link
Member

Reopening as #44326 was reverted. This should be re-fixed by #44982.

@akien-mga akien-mga reopened this Jan 7, 2021
pouleyKetchoupp added a commit to nekomatata/godot that referenced this issue Jan 7, 2021
Adds a cache to the inspector in order to update only modified
properties when the property list changes and keep the previous controls
whenever possible.

This allows calls to property_list_changed_notify to trigger inspector
updates without resetting all properties.

Fixes godotengine#43238 (re-applies godotengine#44326, reverted because of regression godotengine#44854)

Also fixes change signal emission for multiline string properties (same as godotengine#44326 but for multiline strings).
@pouleyKetchoupp
Copy link
Contributor

For info, this still doesn't work on master at the moment (efc8748).

There are two issues:
-value property doesn't appear in the inspector even though it's returned by _get_property_list
-type_string property has text entered backwards (similar as regressions from #44326)

Here's the updated script for 4.0:

@tool
extends Node2D

# This works:
@export var type = TYPE_STRING:
	set(value):
		type = value
		notify_property_list_changed()
		# The property editor for 'value' is successfully instantiated for this type.

# This doesn't work:
@export var type_string : String:
	set(value):
		type_string = value
		match type_string:
			"bool":
				print("Set type via string: bool")
				type = TYPE_BOOL
			"Vector2":
				print("Set type via string: Vector2")
				type = TYPE_VECTOR2
		notify_property_list_changed()
		# The property editor is not replaced with a new type.
		# Expected to update the property of 'value' in the inspector by now.

var value

# The `value`s type is changed dynamically here.
func _get_property_list():
	return [
		{
			"type": type,
			"name": "value"
		}
	]

@KoBeWi
Copy link
Member

KoBeWi commented May 31, 2022

Reproduction project seems broken. value property doesn't appear.

@OscarPindaro
Copy link

I can confirm that this is still a issue. In my project, when changing an exported string variable, other exported values should be resetted, but they keep their original value. A solution to this is to click to anything in the editor, since the editor loses the focus on the current node. When selecting again the node, all the value are properly updated. It's good that there is a work-around, but it's a bit too clunky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants