@@ -91,7 +91,9 @@ void EditorPropertyText::_text_changed(const String &p_string) {
91
91
92
92
// Set tooltip so that the full text is displayed in a tooltip if hovered.
93
93
// This is useful when using a narrow inspector, as the text can be trimmed otherwise.
94
- text->set_tooltip_text (get_tooltip_string (text->get_text ()));
94
+ if (!is_secret || !text->is_secret ()) {
95
+ text->set_tooltip_text (get_tooltip_string (text->get_text ()));
96
+ }
95
97
96
98
if (string_name) {
97
99
emit_changed (get_edited_property (), StringName (p_string));
@@ -100,13 +102,41 @@ void EditorPropertyText::_text_changed(const String &p_string) {
100
102
}
101
103
}
102
104
105
+ void EditorPropertyText::_show_secret_toggled (const bool &p_toggled) {
106
+ text->set_secret (!p_toggled);
107
+ if (p_toggled) {
108
+ text->set_tooltip_text (get_tooltip_string (text->get_text ()));
109
+ show_secret->set_button_icon (get_editor_theme_icon (SNAME (" GuiVisibilityVisible" )));
110
+ } else {
111
+ text->set_tooltip_text (" " );
112
+ show_secret->set_button_icon (get_editor_theme_icon (SNAME (" GuiVisibilityHidden" )));
113
+ }
114
+ }
115
+
116
+ void EditorPropertyText::_notification (int p_what) {
117
+ switch (p_what) {
118
+ case NOTIFICATION_ENTER_TREE:
119
+ case NOTIFICATION_THEME_CHANGED: {
120
+ if (is_secret) {
121
+ if (show_secret->is_pressed ()) {
122
+ show_secret->set_button_icon (get_editor_theme_icon (SNAME (" GuiVisibilityVisible" )));
123
+ } else {
124
+ show_secret->set_button_icon (get_editor_theme_icon (SNAME (" GuiVisibilityHidden" )));
125
+ }
126
+ }
127
+ } break ;
128
+ }
129
+ }
130
+
103
131
void EditorPropertyText::update_property () {
104
132
String s = get_edited_property_value ();
105
133
updating = true ;
106
134
if (text->get_text () != s) {
107
135
int caret = text->get_caret_column ();
108
136
text->set_text (s);
109
- text->set_tooltip_text (get_tooltip_string (s));
137
+ if (!is_secret || !text->is_secret ()) {
138
+ text->set_tooltip_text (get_tooltip_string (s));
139
+ }
110
140
text->set_caret_column (caret);
111
141
}
112
142
text->set_editable (!is_read_only ());
@@ -125,7 +155,23 @@ void EditorPropertyText::set_string_name(bool p_enabled) {
125
155
}
126
156
127
157
void EditorPropertyText::set_secret (bool p_enabled) {
158
+ is_secret = p_enabled;
159
+ if (p_enabled) {
160
+ show_secret = memnew (Button );
161
+ show_secret->set_clip_text (true );
162
+ show_secret->set_toggle_mode (true );
163
+ text->get_parent ()->add_child (show_secret);
164
+ add_focusable (text);
165
+ show_secret->connect (SceneStringName (toggled), callable_mp (this , &EditorPropertyText::_show_secret_toggled));
166
+ } else {
167
+ text->set_tooltip_text (get_tooltip_string (text->get_text ()));
168
+ }
128
169
text->set_secret (p_enabled);
170
+ if (show_secret != nullptr ) {
171
+ show_secret->set_visible (p_enabled);
172
+ show_secret->set_button_icon (get_editor_theme_icon (SNAME (" GuiVisibilityHidden" )));
173
+ show_secret->set_pressed_no_signal (false );
174
+ }
129
175
}
130
176
131
177
void EditorPropertyText::set_placeholder (const String &p_string) {
0 commit comments