Pārlūkot izejas kodu

Update EditorHelp to response help request other than class; Make sure EditorHelpSearch dialog popup with search results

marynate 11 gadi atpakaļ
vecāks
revīzija
ab76f54196
2 mainītis faili ar 22 papildinājumiem un 21 dzēšanām
  1. 21 20
      tools/editor/editor_help.cpp
  2. 1 1
      tools/editor/editor_help.h

+ 21 - 20
tools/editor/editor_help.cpp

@@ -44,15 +44,9 @@ void EditorHelpSearch::popup(const String& p_term) {
 		search_box->set_text(p_term);
 		search_box->select_all();
 		_update_search();
-		//TreeItem *ti = search_options->select_single_item();
-		//if (!ti)
-		//	return;
-		search_options->grab_focus();
-
-	} else {
+	} else
 		search_box->clear();
-		search_box->grab_focus();
-	}
+	search_box->grab_focus();
 }
 
 
@@ -77,7 +71,6 @@ void EditorHelpSearch::_sbox_input(const InputEvent& p_ie) {
 
 void EditorHelpSearch::_update_search() {
 
-
 	search_options->clear();
 	search_options->set_hide_root(true);
 
@@ -256,6 +249,7 @@ void EditorHelpSearch::_confirmed() {
 
 	String mdata=ti->get_metadata(0);
 	emit_signal("go_to_help",mdata);
+	editor->call("_editor_select",3); // in case EditorHelpSearch beeen invoked on top of other editor window
 	// go to that
 	hide();
 }
@@ -325,10 +319,14 @@ DocData *EditorHelp::doc=NULL;
 
 void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) {
 
-	if (is_visible() && p_ev.key.mod.control && p_ev.key.scancode==KEY_F) {
+	if (!is_visible())
+		return;
+	if ( p_ev.key.mod.control && p_ev.key.scancode==KEY_F) {
 
 		search->grab_focus();
 		search->select_all();
+	} else if (p_ev.key.mod.shift && p_ev.key.scancode==KEY_F1) {
+		class_search->popup();
 	}
 }
 
@@ -461,9 +459,11 @@ void EditorHelp::_scroll_changed(double p_scroll) {
 	history[p].scroll=p_scroll;
 }
 
-void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vscr) {
+Error EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vscr) {
 
-	ERR_FAIL_COND(!doc->class_list.has(p_class));
+	//ERR_FAIL_COND(!doc->class_list.has(p_class));
+	if (!doc->class_list.has(p_class))
+		return ERR_DOES_NOT_EXIST;
 
 
 	if (tree_item_map.has(p_class)) {
@@ -477,7 +477,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
 	description_line=0;
 
 	if (p_class==edited_class->get_text())
-		return; //already there
+		return OK; //already there
 
 	scroll_locked=true;
 
@@ -865,15 +865,16 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
 
 	scroll_locked=false;
 
+	return OK;
 }
 
-void EditorHelp::_request_help(const String& p_string) {
-
-	_goto_desc(p_string);
-	class_search->popup(p_string);
-
-
-
+void EditorHelp::_request_help(const String& p_string) {	
+	Error err = _goto_desc(p_string);
+	if (err==OK) {
+		editor->call("_editor_select",3);
+	} else {
+		class_search->popup(p_string);
+	}
 	//100 palabras
 }
 

+ 1 - 1
tools/editor/editor_help.h

@@ -139,7 +139,7 @@ class EditorHelp : public VBoxContainer {
 	void _class_list_select(const String& p_select);
 	void _class_desc_select(const String& p_select);
 
-	void _goto_desc(const String& p_class,bool p_update_history=true,int p_vscr=-1);
+	Error _goto_desc(const String& p_class,bool p_update_history=true,int p_vscr=-1);
 	void _update_history_buttons();
 	void _update_doc();