summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-05-18 18:59:22 +0200
committerGitHub <noreply@github.com>2017-05-18 18:59:22 +0200
commit0aede444ef2cea5bfd830ff5a1e7db6e1373cfc4 (patch)
tree2a0050dd0d76c138ae81484ba239d32826a10bf7 /editor/editor_node.cpp
parent1f62c331412f7f89bae7655c50cbbdf99f972082 (diff)
parent3be8a94868110f107454f4e9ae12c0db5c04c858 (diff)
Merge pull request #8789 from Hinsbart/editor_shortcuts
Editor: Make "open 2d/3d/script editor" shortcuts configurable.
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp69
1 files changed, 47 insertions, 22 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index a9014ad97b..42de85ec00 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -194,28 +194,20 @@ void EditorNode::_unhandled_input(const InputEvent &p_event) {
filesystem_dock->focus_on_filter();
}
- switch (p_event.key.scancode) {
-
- /*case KEY_F1:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_SCRIPT);
- break;*/
- case KEY_F1:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_2D);
- break;
- case KEY_F2:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_3D);
- break;
- case KEY_F3:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_SCRIPT);
- break;
- /* case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break;
- case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break;
- //case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break;
- case KEY_F8: _menu_option_confirm(RUN_STOP,true); break;*/
+ if (ED_IS_SHORTCUT("editor/editor_2d", p_event)) {
+ _editor_select(EDITOR_2D);
+ } else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) {
+ _editor_select(EDITOR_3D);
+ } else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) {
+ _editor_select(EDITOR_SCRIPT);
+ } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) {
+ emit_signal("request_help_search", "");
+ } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event)) {
+ _editor_select(EDITOR_ASSETLIB);
+ } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) {
+ _editor_select_next();
+ } else if (ED_IS_SHORTCUT("editor/editor_prev", p_event)) {
+ _editor_select_prev();
}
}
}
@@ -454,6 +446,30 @@ void EditorNode::_node_renamed() {
property_editor->update_tree();
}
+void EditorNode::_editor_select_next() {
+
+ int editor = _get_current_main_editor();
+
+ if (editor == editor_table.size() - 1) {
+ editor = 0;
+ } else {
+ editor++;
+ }
+ _editor_select(editor);
+}
+
+void EditorNode::_editor_select_prev() {
+
+ int editor = _get_current_main_editor();
+
+ if (editor == 0) {
+ editor = editor_table.size() - 1;
+ } else {
+ editor--;
+ }
+ _editor_select(editor);
+}
+
Error EditorNode::load_resource(const String &p_scene) {
RES res = ResourceLoader::load(p_scene);
@@ -4796,6 +4812,7 @@ void EditorNode::_bind_methods() {
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
ADD_SIGNAL(MethodInfo("request_help"));
+ ADD_SIGNAL(MethodInfo("request_help_search"));
ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::POOL_STRING_ARRAY, "args")));
ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "obj")));
}
@@ -6112,6 +6129,14 @@ EditorNode::EditorNode() {
_dim_timer->set_wait_time(0.01666f);
_dim_timer->connect("timeout", this, "_dim_timeout");
add_child(_dim_timer);
+
+ ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F2);
+ ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F3);
+ ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F4);
+ ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1);
+ ED_SHORTCUT("editor/editor_assetlib", TTR("Open Asset Library"));
+ ED_SHORTCUT("editor/editor_next", TTR("Open the next Editor"));
+ ED_SHORTCUT("editor/editor_prev", TTR("Open the previous Editor"));
}
EditorNode::~EditorNode() {