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

Add ok_button_text to AcceptDialog and cancel_button_text to ConfirmationDialog #62827

Merged
merged 1 commit into from
Jul 13, 2022

Conversation

fire-forge
Copy link
Contributor

Closes godotengine/godot-proposals#2419

Adds an ok_button_text property to AcceptDialog and cancel_button_text property to ConfirmationDialog. The main advantage of having these properties is to allow setting the OK and Cancel buttons' text from the inspector without requiring the use of a script.

image

Also documents AcceptDialog.dialog_close_on_escape since it was the only undocumented part of AcceptDialog.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@KoBeWi
Copy link
Member

KoBeWi commented Jul 8, 2022

It seems to have problem similar to #39258
image
The properties will get translated, but unlike that issue the translated property doesn't seem get serialized 🤔

@bruvzg
Copy link
Member

bruvzg commented Jul 8, 2022

The properties will get translated, but unlike that issue the translated property doesn't seem get serialized 🤔

It's probably should store untranslated text as a public property and translated copy for the internal use like Label and Button do (since it is setting Button text, it's probably should avoid translating anything at all, button will do the rest automatically).

case NOTIFICATION_TRANSLATION_CHANGED: {
xl_text = atr(text);

godot/scene/gui/button.cpp

Lines 383 to 386 in ca18a02

void Button::set_text(const String &p_text) {
if (text != p_text) {
text = p_text;
xl_text = atr(text);

@fire-forge
Copy link
Contributor Author

It's probably should store untranslated text as a public property and translated copy for the internal use like Label and Button do (since it is setting Button text, it's probably should avoid translating anything at all, button will do the rest automatically).

I've updated the PR to store untranslated text. Button seems to handle translation automatically.

@akien-mga akien-mga merged commit b942c1f into godotengine:master Jul 13, 2022
@akien-mga
Copy link
Member

Thanks!

@fire-forge fire-forge deleted the ok-cancel branch July 13, 2022 17:01
@KoBeWi
Copy link
Member

KoBeWi commented Feb 21, 2023

I didn't notice it then, but the FileDialog does translate the text and stores it in the scene :/
image
It would be great if this text wasn't stored at all; it depends on file mode anyway. Might require some clever usage of _validate_property().

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

Successfully merging this pull request may close these issues.

Add ok_button_text and cancel_button_text properties to ConfirmationDialog
5 participants