summaryrefslogtreecommitdiff
path: root/tools/editor/editor_file_dialog.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2016-01-07 07:50:26 +0100
committerRémi Verschelde <remi@verschelde.fr>2016-01-07 07:50:26 +0100
commita0c39a4b333a2f05c9bb2ccf1be71ac8e18fc9a9 (patch)
tree65adefee4110375ba3653c1b952217dbf1ea4390 /tools/editor/editor_file_dialog.cpp
parentc874ad3f52d383ea189f1cd70f07fb01b21e491f (diff)
parent3ca800226ece276d1ff568650134e8857840bfbb (diff)
Merge pull request #3191 from neikeq/filedialog_hotkeys
Add keyboard shortcut to toggle "show hidden files" in FileDialog
Diffstat (limited to 'tools/editor/editor_file_dialog.cpp')
-rw-r--r--tools/editor/editor_file_dialog.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp
index 28a9b63412..22cd3845e1 100644
--- a/tools/editor/editor_file_dialog.cpp
+++ b/tools/editor/editor_file_dialog.cpp
@@ -53,13 +53,52 @@ void EditorFileDialog::_notification(int p_what) {
//RID ci = get_canvas_item();
//get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
+ } else if (p_what==NOTIFICATION_POPUP_HIDE) {
+
+ set_process_unhandled_input(false);
+
} else if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- set_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
+ bool show_hidden=EditorSettings::get_singleton()->get("file_dialog/show_hidden_files");
+ if (show_hidden_files!=show_hidden)
+ set_show_hidden_files(show_hidden);
set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("file_dialog/display_mode").operator int());
}
}
+void EditorFileDialog::_unhandled_input(const InputEvent& p_event) {
+
+ if (p_event.type==InputEvent::KEY && is_window_modal_on_top()) {
+
+ const InputEventKey &k=p_event.key;
+
+ if (k.pressed) {
+
+ bool handled=true;
+
+ switch (k.scancode) {
+
+ case KEY_H: {
+
+ if (k.mod.command) {
+
+ bool show=!show_hidden_files;
+ set_show_hidden_files(show);
+ EditorSettings::get_singleton()->set("file_dialog/show_hidden_files",show);
+ } else {
+ handled=false;
+ }
+
+ } break;
+ default: { handled=false; }
+ }
+
+ if (handled)
+ accept_event();
+ }
+ }
+}
+
void EditorFileDialog::set_enable_multiple_selection(bool p_enable) {
item_list->set_select_mode(p_enable?ItemList::SELECT_MULTI:ItemList::SELECT_SINGLE);
@@ -151,6 +190,8 @@ void EditorFileDialog::_post_popup() {
_update_favorites();
}
+ set_process_unhandled_input(true);
+
}
void EditorFileDialog::_thumbnail_result(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) {
@@ -1049,6 +1090,8 @@ EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{
void EditorFileDialog::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("_unhandled_input"),&EditorFileDialog::_unhandled_input);
+
ObjectTypeDB::bind_method(_MD("_item_selected"),&EditorFileDialog::_item_selected);
ObjectTypeDB::bind_method(_MD("_item_db_selected"),&EditorFileDialog::_item_dc_selected);
ObjectTypeDB::bind_method(_MD("_dir_entered"),&EditorFileDialog::_dir_entered);