From 9605fc54c790b1c4364bc0eddfcdd65f979bfc21 Mon Sep 17 00:00:00 2001 From: Daniel Ting Date: Wed, 8 Jul 2020 18:02:38 -0500 Subject: [PATCH] Fix cancel/OK button order on macOS The macOS platform convention regarding button order is cancel on left, OK on right. --- doc/classes/DisplayServer.xml | 2 +- doc/classes/ProjectSettings.xml | 4 ++-- editor/editor_dir_dialog.cpp | 2 +- editor/editor_node.cpp | 4 ++-- editor/plugins/script_editor_plugin.cpp | 4 ++-- editor/plugins/shader_editor_plugin.cpp | 2 +- editor/project_export.cpp | 4 ++-- platform/osx/display_server_osx.h | 2 +- platform/osx/display_server_osx.mm | 4 ++-- platform/uwp/os_uwp.h | 2 +- platform/windows/display_server_windows.cpp | 2 +- platform/windows/display_server_windows.h | 2 +- scene/gui/dialogs.cpp | 8 ++++---- scene/gui/dialogs.h | 4 ++-- scene/register_scene_types.cpp | 2 +- servers/display_server.cpp | 4 ++-- servers/display_server.h | 2 +- 17 files changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index d118cf82057..49af8d7de26 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -139,7 +139,7 @@ - + diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index c8427ac61f9..e255ce2e1a4 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -472,8 +472,8 @@ Default value for [member ScrollContainer.scroll_deadzone], which will be used for all [ScrollContainer]s unless overridden. - - If [code]true[/code], swaps OK and Cancel buttons in dialogs on Windows and UWP to follow interface conventions. + + If [code]true[/code], swaps Cancel and OK buttons in dialogs on Windows and UWP to follow interface conventions. diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 3c1c3c8a86a..206fdef7c9a 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -182,7 +182,7 @@ EditorDirDialog::EditorDirDialog() { tree->connect("item_activated", callable_mp(this, &EditorDirDialog::_item_activated)); - makedir = add_button(TTR("Create Folder"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "makedir"); + makedir = add_button(TTR("Create Folder"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "makedir"); makedir->connect("pressed", callable_mp(this, &EditorDirDialog::_make_dir)); makedialog = memnew(ConfirmationDialog); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f768a2cacf2..38c08b1fd03 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6478,7 +6478,7 @@ EditorNode::EditorNode() { confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); save_confirmation = memnew(ConfirmationDialog); - save_confirmation->add_button(TTR("Don't Save"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "discard"); + save_confirmation->add_button(TTR("Don't Save"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard"); gui_base->add_child(save_confirmation); save_confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); save_confirmation->connect("custom_action", callable_mp(this, &EditorNode::_discard_changes)); @@ -6697,7 +6697,7 @@ EditorNode::EditorNode() { open_imported = memnew(ConfirmationDialog); open_imported->get_ok()->set_text(TTR("Open Anyway")); - new_inherited_button = open_imported->add_button(TTR("New Inherited"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "inherit"); + new_inherited_button = open_imported->add_button(TTR("New Inherited"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "inherit"); open_imported->connect("confirmed", callable_mp(this, &EditorNode::_open_imported)); open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported)); gui_base->add_child(open_imported); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 8386d44e692..9d222401fb0 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3166,7 +3166,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { erase_tab_confirm = memnew(ConfirmationDialog); erase_tab_confirm->get_ok()->set_text(TTR("Save")); - erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "discard"); + erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard"); erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab)); erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab)); add_child(erase_tab_confirm); @@ -3200,7 +3200,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { disk_changed->connect("confirmed", callable_mp(this, &ScriptEditor::_reload_scripts)); disk_changed->get_ok()->set_text(TTR("Reload")); - disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "resave"); + disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts)); } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 7dd0b8a2387..2542b7011bb 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -669,7 +669,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk)); disk_changed->get_ok()->set_text(TTR("Reload")); - disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "resave"); + disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &ShaderEditor::save_external_data)); add_child(disk_changed); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 67ab925a4f2..a7be81414ff 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1248,7 +1248,7 @@ ProjectExportDialog::ProjectExportDialog() { get_cancel()->set_text(TTR("Close")); get_ok()->set_text(TTR("Export PCK/Zip")); - export_button = add_button(TTR("Export Project"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "export"); + export_button = add_button(TTR("Export Project"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "export"); export_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_project)); // Disable initially before we select a valid preset export_button->set_disabled(true); @@ -1263,7 +1263,7 @@ ProjectExportDialog::ProjectExportDialog() { export_all_dialog->add_button(TTR("Release"), true, "release"); export_all_dialog->connect("custom_action", callable_mp(this, &ProjectExportDialog::_export_all_dialog_action)); - export_all_button = add_button(TTR("Export All"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "export"); + export_all_button = add_button(TTR("Export All"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "export"); export_all_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_all_dialog)); export_all_button->set_disabled(true); diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h index c636463e689..68e8454fd02 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/osx/display_server_osx.h @@ -288,7 +288,7 @@ public: virtual CursorShape cursor_get_shape() const override; virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) override; - virtual bool get_swap_ok_cancel() override; + virtual bool get_swap_cancel_ok() override; virtual int keyboard_get_layout_count() const override; virtual int keyboard_get_current_layout() const override; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 07ecd5d2c6a..19d7540c939 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -2913,8 +2913,8 @@ void DisplayServerOSX::window_set_ime_position(const Point2i &p_pos, WindowID p_ wd.im_position = p_pos; } -bool DisplayServerOSX::get_swap_ok_cancel() { - return true; +bool DisplayServerOSX::get_swap_cancel_ok() { + return false; } void DisplayServerOSX::cursor_set_shape(CursorShape p_shape) { diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 95359c68b06..c35b6343531 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -245,7 +245,7 @@ public: void run(); - virtual bool get_swap_ok_cancel() { return true; } + virtual bool get_swap_cancel_ok() { return true; } void input_event(const Ref &p_event); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 103e858d97a..72a63377721 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1367,7 +1367,7 @@ void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorSh } } -bool DisplayServerWindows::get_swap_ok_cancel() { +bool DisplayServerWindows::get_swap_cancel_ok() { return true; } diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 8433bb449b3..725f9697c5c 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -520,7 +520,7 @@ public: virtual CursorShape cursor_get_shape() const; virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()); - virtual bool get_swap_ok_cancel(); + virtual bool get_swap_cancel_ok(); virtual void enable_for_stealing_focus(OS::ProcessID pid); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index faef9790907..9077bfa4ba9 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -258,7 +258,7 @@ Button *AcceptDialog::add_cancel(const String &p_cancel) { if (p_cancel == "") { c = RTR("Cancel"); } - Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c); + Button *b = swap_cancel_ok ? add_button(c, true) : add_button(c); b->connect("pressed", callable_mp(this, &AcceptDialog::_cancel_pressed)); return b; } @@ -286,9 +286,9 @@ void AcceptDialog::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_autowrap"), "set_autowrap", "has_autowrap"); } -bool AcceptDialog::swap_ok_cancel = false; -void AcceptDialog::set_swap_ok_cancel(bool p_swap) { - swap_ok_cancel = p_swap; +bool AcceptDialog::swap_cancel_ok = false; +void AcceptDialog::set_swap_cancel_ok(bool p_swap) { + swap_cancel_ok = p_swap; } AcceptDialog::AcceptDialog() { diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index 063090c832b..de08685ce2a 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -54,7 +54,7 @@ class AcceptDialog : public Window { void _custom_action(const String &p_action); void _update_child_rects(); - static bool swap_ok_cancel; + static bool swap_cancel_ok; void _input_from_window(const Ref &p_event); void _parent_focused(); @@ -75,7 +75,7 @@ protected: public: Label *get_label() { return label; } - static void set_swap_ok_cancel(bool p_swap); + static void set_swap_cancel_ok(bool p_swap); void register_text_enter(Node *p_line_edit); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index f40fb780561..1c91effe051 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -369,7 +369,7 @@ void register_scene_types() { OS::get_singleton()->yield(); //may take time to init - AcceptDialog::set_swap_ok_cancel(GLOBAL_DEF("gui/common/swap_ok_cancel", bool(DisplayServer::get_singleton()->get_swap_ok_cancel()))); + AcceptDialog::set_swap_cancel_ok(GLOBAL_DEF("gui/common/swap_cancel_ok", bool(DisplayServer::get_singleton()->get_swap_cancel_ok()))); #endif /* REGISTER 3D */ diff --git a/servers/display_server.cpp b/servers/display_server.cpp index 72cfd878808..65db0de0018 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -238,7 +238,7 @@ void DisplayServer::cursor_set_custom_image(const RES &p_cursor, CursorShape p_s WARN_PRINT("Custom cursor shape not supported by this display server."); } -bool DisplayServer::get_swap_ok_cancel() { +bool DisplayServer::get_swap_cancel_ok() { return false; } @@ -464,7 +464,7 @@ void DisplayServer::_bind_methods() { ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape); ClassDB::bind_method(D_METHOD("cursor_set_custom_image", "cursor", "shape", "hotspot"), &DisplayServer::cursor_set_custom_image, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2())); - ClassDB::bind_method(D_METHOD("get_swap_ok_cancel"), &DisplayServer::get_swap_ok_cancel); + ClassDB::bind_method(D_METHOD("get_swap_cancel_ok"), &DisplayServer::get_swap_cancel_ok); ClassDB::bind_method(D_METHOD("enable_for_stealing_focus", "process_id"), &DisplayServer::enable_for_stealing_focus); diff --git a/servers/display_server.h b/servers/display_server.h index 79f6f5d0fc0..2cf0a83dbd8 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -318,7 +318,7 @@ public: virtual CursorShape cursor_get_shape() const; virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()); - virtual bool get_swap_ok_cancel(); + virtual bool get_swap_cancel_ok(); virtual void enable_for_stealing_focus(OS::ProcessID pid);