From 8c06dce33f3ab242f2a988fac3209c73bb8cda17 Mon Sep 17 00:00:00 2001
From: Relintai <relintai@protonmail.com>
Date: Sun, 25 Feb 2024 22:09:25 +0100
Subject: [PATCH] Now PROPERTY_HINT_BUTTON adds the property's name as the
 called method's first parameter.

---
 core/object/object.h                                            | 2 +-
 doc/classes/@GlobalScope.xml                                    | 2 +-
 editor/editor_properties.cpp                                    | 2 +-
 .../gdnative/include/nativescript/pandemonium_nativescript.h    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/object/object.h b/core/object/object.h
index bea207f054..58b4a53a26 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -63,7 +63,7 @@ enum PropertyHint {
 	PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
 	PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "full" to also include in/out. (ie: "attenuation,inout")
 	PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
-	PROPERTY_HINT_BUTTON, // Use a button in the inspector for this property. The property's type has to be Variant::NIL. hint_text="call_func:name/theme_type" -> calls call_func on press, optional: ":name/theme_type" -> get_theme_icon("name", "theme_type")
+	PROPERTY_HINT_BUTTON, // Use a button in the inspector for this property. The property's type has to be Variant::NIL. hint_text="call_func:name/theme_type" -> calls call_func(const StringName &p_property) on press, optional: ":name/theme_type" -> get_theme_icon("name", "theme_type")
 	PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
 	PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
 	PROPERTY_HINT_LAYERS_2D_RENDER,
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 817ddf0c6c..8376a13ce6 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -1464,7 +1464,7 @@
 			Deprecated hint, unused.
 		</constant>
 		<constant name="PROPERTY_HINT_BUTTON" value="6" enum="PropertyHint">
-			Use a button in the inspector for this property. The property's type has to be Variant::NIL. The hint string has to contain a method that you want called. [code]"my_method"[/code] will call [code]my_method()[/code] on press. Optionally it can also contain a theme icon like: [code]"my_method:name/theme_type"[/code] -&gt; [code]get_theme_icon("name", "theme_type")[/code]
+			Use a button in the inspector for this property. The property's type has to be Variant::NIL. The hint string has to contain a method that you want called. [code]"my_method"[/code] will call [code]my_method(property : StringName)[/code] on press. Optionally it can also contain a theme icon like: [code]"my_method:name/theme_type"[/code] -&gt; [code]get_theme_icon("name", "theme_type")[/code]
 		</constant>
 		<constant name="PROPERTY_HINT_KEY_ACCEL" value="7" enum="PropertyHint">
 			Deprecated hint, unused.
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index ed636a9af2..3f34bc0557 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -688,7 +688,7 @@ void EditorPropertyButton::_button_pressed() {
 	//get_edited_object()->get(get_edited_property());
 
 	if (_method_name != "") {
-		get_edited_object()->call(_method_name);
+		get_edited_object()->call(_method_name, get_edited_property());
 	}
 }
 
diff --git a/modules/gdnative/include/nativescript/pandemonium_nativescript.h b/modules/gdnative/include/nativescript/pandemonium_nativescript.h
index 40decd9879..69a1bab6cb 100644
--- a/modules/gdnative/include/nativescript/pandemonium_nativescript.h
+++ b/modules/gdnative/include/nativescript/pandemonium_nativescript.h
@@ -55,7 +55,7 @@ typedef enum {
 	PANDEMONIUM_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
 	PANDEMONIUM_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "full" to also include in/out. (ie: "attenuation,inout")
 	PANDEMONIUM_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
-	PANDEMONIUM_PROPERTY_HINT_BUTTON, // Use a button in the inspector for this property. The property's type has to be Variant::NIL. hint_text="call_func:name/theme_type" -> calls call_func on press, optional: ":name/theme_type" -> get_theme_icon("name", "theme_type")
+	PANDEMONIUM_PROPERTY_HINT_BUTTON, // Use a button in the inspector for this property. The property's type has to be Variant::NIL. hint_text="call_func:name/theme_type" -> calls call_func(const StringName &p_property) on press, optional: ":name/theme_type" -> get_theme_icon("name", "theme_type")
 	PANDEMONIUM_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
 	PANDEMONIUM_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
 	PANDEMONIUM_PROPERTY_HINT_LAYERS_2D_RENDER,