瀏覽代碼

Focus path field after seleting file browser on Attach script window

volzhs 7 年之前
父節點
當前提交
ac411c9f48
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      editor/script_create_dialog.cpp

+ 6 - 0
editor/script_create_dialog.cpp

@@ -331,6 +331,12 @@ void ScriptCreateDialog::_file_selected(const String &p_file) {
 	} else {
 		file_path->set_text(p);
 		_path_changed(p);
+
+		String filename = p.get_file().get_basename();
+		int select_start = p.find_last(filename);
+		file_path->select(select_start, select_start + filename.length());
+		file_path->set_cursor_position(select_start + filename.length());
+		file_path->grab_focus();
 	}
 }