Added a setting to disable autocomplete popup and fixed the autocomplete timer to updated when the setting has changed

This commit is contained in:
Jonas Rudlang 2014-05-22 00:01:11 +02:00
parent 8bb7cc7325
commit 6b1b3fbfa5
2 changed files with 12 additions and 3 deletions

View file

@ -484,7 +484,7 @@ void CodeTextEditor::_text_changed() {
} }
void CodeTextEditor::_code_complete_timer_timeout() { void CodeTextEditor::_code_complete_timer_timeout() {
if (enable_complete_timer)
text_editor->query_code_comple(); text_editor->query_code_comple();
} }
@ -535,6 +535,11 @@ void CodeTextEditor::_on_settings_change() {
EDITOR_DEF("text_editor/auto_brace_complete", false) EDITOR_DEF("text_editor/auto_brace_complete", false)
); );
code_complete_timer->set_wait_time(
EDITOR_DEF("text_editor/code_complete_delay",.3f)
);
enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true);
} }
void CodeTextEditor::_text_changed_idle_timeout() { void CodeTextEditor::_text_changed_idle_timeout() {
@ -584,6 +589,8 @@ CodeTextEditor::CodeTextEditor() {
code_complete_timer = memnew(Timer); code_complete_timer = memnew(Timer);
add_child(code_complete_timer); add_child(code_complete_timer);
code_complete_timer->set_one_shot(true); code_complete_timer->set_one_shot(true);
enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true);
code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/code_complete_delay",.3f)); code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/code_complete_delay",.3f));
error = memnew( Label ); error = memnew( Label );
@ -604,6 +611,7 @@ CodeTextEditor::CodeTextEditor() {
cs.push_back("."); cs.push_back(".");
text_editor->set_completion(true,cs); text_editor->set_completion(true,cs);
idle->connect("timeout", this,"_text_changed_idle_timeout"); idle->connect("timeout", this,"_text_changed_idle_timeout");
code_complete_timer->connect("timeout", this,"_code_complete_timer_timeout"); code_complete_timer->connect("timeout", this,"_code_complete_timer_timeout");
EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change"); EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change");

View file

@ -129,6 +129,7 @@ class CodeTextEditor : public Control {
Label *info; Label *info;
Timer *idle; Timer *idle;
Timer *code_complete_timer; Timer *code_complete_timer;
bool enable_complete_timer;
Label *error; Label *error;