Fix cancel/OK button order on macOS

The macOS platform convention regarding button order is cancel on left,
OK on right.
This commit is contained in:
Daniel Ting 2020-07-08 18:02:38 -05:00
parent dcd11faad3
commit 9605fc54c7
17 changed files with 27 additions and 27 deletions

View file

@ -139,7 +139,7 @@
<description> <description>
</description> </description>
</method> </method>
<method name="get_swap_ok_cancel"> <method name="get_swap_cancel_ok">
<return type="bool"> <return type="bool">
</return> </return>
<description> <description>

View file

@ -472,8 +472,8 @@
<member name="gui/common/default_scroll_deadzone" type="int" setter="" getter="" default="0"> <member name="gui/common/default_scroll_deadzone" type="int" setter="" getter="" default="0">
Default value for [member ScrollContainer.scroll_deadzone], which will be used for all [ScrollContainer]s unless overridden. Default value for [member ScrollContainer.scroll_deadzone], which will be used for all [ScrollContainer]s unless overridden.
</member> </member>
<member name="gui/common/swap_ok_cancel" type="bool" setter="" getter="" default="false"> <member name="gui/common/swap_cancel_ok" type="bool" setter="" getter="" default="false">
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.
</member> </member>
<member name="gui/common/text_edit_undo_stack_max_size" type="int" setter="" getter="" default="1024"> <member name="gui/common/text_edit_undo_stack_max_size" type="int" setter="" getter="" default="1024">
</member> </member>

View file

@ -182,7 +182,7 @@ EditorDirDialog::EditorDirDialog() {
tree->connect("item_activated", callable_mp(this, &EditorDirDialog::_item_activated)); 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)); makedir->connect("pressed", callable_mp(this, &EditorDirDialog::_make_dir));
makedialog = memnew(ConfirmationDialog); makedialog = memnew(ConfirmationDialog);

View file

@ -6478,7 +6478,7 @@ EditorNode::EditorNode() {
confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
save_confirmation = memnew(ConfirmationDialog); 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); gui_base->add_child(save_confirmation);
save_confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); save_confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
save_confirmation->connect("custom_action", callable_mp(this, &EditorNode::_discard_changes)); save_confirmation->connect("custom_action", callable_mp(this, &EditorNode::_discard_changes));
@ -6697,7 +6697,7 @@ EditorNode::EditorNode() {
open_imported = memnew(ConfirmationDialog); open_imported = memnew(ConfirmationDialog);
open_imported->get_ok()->set_text(TTR("Open Anyway")); 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("confirmed", callable_mp(this, &EditorNode::_open_imported));
open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported)); open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported));
gui_base->add_child(open_imported); gui_base->add_child(open_imported);

View file

@ -3166,7 +3166,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
erase_tab_confirm = memnew(ConfirmationDialog); erase_tab_confirm = memnew(ConfirmationDialog);
erase_tab_confirm->get_ok()->set_text(TTR("Save")); 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("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab));
erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab)); erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab));
add_child(erase_tab_confirm); 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->connect("confirmed", callable_mp(this, &ScriptEditor::_reload_scripts));
disk_changed->get_ok()->set_text(TTR("Reload")); 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)); disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts));
} }

View file

@ -669,7 +669,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk)); disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk));
disk_changed->get_ok()->set_text(TTR("Reload")); 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)); disk_changed->connect("custom_action", callable_mp(this, &ShaderEditor::save_external_data));
add_child(disk_changed); add_child(disk_changed);

View file

@ -1248,7 +1248,7 @@ ProjectExportDialog::ProjectExportDialog() {
get_cancel()->set_text(TTR("Close")); get_cancel()->set_text(TTR("Close"));
get_ok()->set_text(TTR("Export PCK/Zip")); 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)); export_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_project));
// Disable initially before we select a valid preset // Disable initially before we select a valid preset
export_button->set_disabled(true); export_button->set_disabled(true);
@ -1263,7 +1263,7 @@ ProjectExportDialog::ProjectExportDialog() {
export_all_dialog->add_button(TTR("Release"), true, "release"); 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_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->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_all_dialog));
export_all_button->set_disabled(true); export_all_button->set_disabled(true);

View file

@ -288,7 +288,7 @@ public:
virtual CursorShape cursor_get_shape() const override; 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 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_layout_count() const override;
virtual int keyboard_get_current_layout() const override; virtual int keyboard_get_current_layout() const override;

View file

@ -2913,8 +2913,8 @@ void DisplayServerOSX::window_set_ime_position(const Point2i &p_pos, WindowID p_
wd.im_position = p_pos; wd.im_position = p_pos;
} }
bool DisplayServerOSX::get_swap_ok_cancel() { bool DisplayServerOSX::get_swap_cancel_ok() {
return true; return false;
} }
void DisplayServerOSX::cursor_set_shape(CursorShape p_shape) { void DisplayServerOSX::cursor_set_shape(CursorShape p_shape) {

View file

@ -245,7 +245,7 @@ public:
void run(); void run();
virtual bool get_swap_ok_cancel() { return true; } virtual bool get_swap_cancel_ok() { return true; }
void input_event(const Ref<InputEvent> &p_event); void input_event(const Ref<InputEvent> &p_event);

View file

@ -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; return true;
} }

View file

@ -520,7 +520,7 @@ public:
virtual CursorShape cursor_get_shape() const; 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 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); virtual void enable_for_stealing_focus(OS::ProcessID pid);

View file

@ -258,7 +258,7 @@ Button *AcceptDialog::add_cancel(const String &p_cancel) {
if (p_cancel == "") { if (p_cancel == "") {
c = RTR("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)); b->connect("pressed", callable_mp(this, &AcceptDialog::_cancel_pressed));
return b; return b;
} }
@ -286,9 +286,9 @@ void AcceptDialog::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_autowrap"), "set_autowrap", "has_autowrap"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_autowrap"), "set_autowrap", "has_autowrap");
} }
bool AcceptDialog::swap_ok_cancel = false; bool AcceptDialog::swap_cancel_ok = false;
void AcceptDialog::set_swap_ok_cancel(bool p_swap) { void AcceptDialog::set_swap_cancel_ok(bool p_swap) {
swap_ok_cancel = p_swap; swap_cancel_ok = p_swap;
} }
AcceptDialog::AcceptDialog() { AcceptDialog::AcceptDialog() {

View file

@ -54,7 +54,7 @@ class AcceptDialog : public Window {
void _custom_action(const String &p_action); void _custom_action(const String &p_action);
void _update_child_rects(); void _update_child_rects();
static bool swap_ok_cancel; static bool swap_cancel_ok;
void _input_from_window(const Ref<InputEvent> &p_event); void _input_from_window(const Ref<InputEvent> &p_event);
void _parent_focused(); void _parent_focused();
@ -75,7 +75,7 @@ protected:
public: public:
Label *get_label() { return label; } 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); void register_text_enter(Node *p_line_edit);

View file

@ -369,7 +369,7 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init 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 #endif
/* REGISTER 3D */ /* REGISTER 3D */

View file

@ -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."); 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; 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_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("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); ClassDB::bind_method(D_METHOD("enable_for_stealing_focus", "process_id"), &DisplayServer::enable_for_stealing_focus);

View file

@ -318,7 +318,7 @@ public:
virtual CursorShape cursor_get_shape() const; 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 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); virtual void enable_for_stealing_focus(OS::ProcessID pid);