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

This commit is contained in:
marynate 2014-05-06 17:41:19 +08:00
parent d3b7f4b1a7
commit ab76f54196
2 changed files with 22 additions and 21 deletions

View File

@ -44,15 +44,9 @@ void EditorHelpSearch::popup(const String& p_term) {
search_box->set_text(p_term); search_box->set_text(p_term);
search_box->select_all(); search_box->select_all();
_update_search(); _update_search();
//TreeItem *ti = search_options->select_single_item(); } else
//if (!ti)
// return;
search_options->grab_focus();
} else {
search_box->clear(); 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() { void EditorHelpSearch::_update_search() {
search_options->clear(); search_options->clear();
search_options->set_hide_root(true); search_options->set_hide_root(true);
@ -256,6 +249,7 @@ void EditorHelpSearch::_confirmed() {
String mdata=ti->get_metadata(0); String mdata=ti->get_metadata(0);
emit_signal("go_to_help",mdata); 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 // go to that
hide(); hide();
} }
@ -325,10 +319,14 @@ DocData *EditorHelp::doc=NULL;
void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) { 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->grab_focus();
search->select_all(); 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; 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)) { 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; description_line=0;
if (p_class==edited_class->get_text()) if (p_class==edited_class->get_text())
return; //already there return OK; //already there
scroll_locked=true; 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; scroll_locked=false;
return OK;
} }
void EditorHelp::_request_help(const String& p_string) { void EditorHelp::_request_help(const String& p_string) {
Error err = _goto_desc(p_string);
_goto_desc(p_string); if (err==OK) {
class_search->popup(p_string); editor->call("_editor_select",3);
} else {
class_search->popup(p_string);
}
//100 palabras //100 palabras
} }

View File

@ -139,7 +139,7 @@ class EditorHelp : public VBoxContainer {
void _class_list_select(const String& p_select); void _class_list_select(const String& p_select);
void _class_desc_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_history_buttons();
void _update_doc(); void _update_doc();