Added setting to toggle line edit caret blink

This commit is contained in:
Paulb23 2016-06-21 14:38:35 +01:00
parent e09e036565
commit 4f54e72189
2 changed files with 26 additions and 1 deletions

View file

@ -31,6 +31,9 @@
#include "os/os.h" #include "os/os.h"
#include "print_string.h" #include "print_string.h"
#include "label.h" #include "label.h"
#ifdef TOOLS_ENABLED
#include "tools/editor/editor_settings.h"
#endif
static bool _is_text_char(CharType c) { static bool _is_text_char(CharType c) {
@ -544,7 +547,16 @@ void LineEdit::drop_data(const Point2& p_point,const Variant& p_data){
void LineEdit::_notification(int p_what) { void LineEdit::_notification(int p_what) {
switch(p_what) { switch(p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_ENTER_TREE: {
if (get_tree()->is_editor_hint()) {
cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
}
} break;
#endif
case NOTIFICATION_RESIZED: { case NOTIFICATION_RESIZED: {
set_cursor_pos( get_cursor_pos() ); set_cursor_pos( get_cursor_pos() );
@ -1185,10 +1197,21 @@ PopupMenu *LineEdit::get_menu() const {
return menu; return menu;
} }
#ifdef TOOLS_ENABLED
void LineEdit::_editor_settings_changed() {
cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
}
#endif
void LineEdit::_bind_methods() { void LineEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret); ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
#ifdef TOOLS_ENABLED
ObjectTypeDB::bind_method("_editor_settings_changed",&LineEdit::_editor_settings_changed);
#endif
ObjectTypeDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align); ObjectTypeDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align);
ObjectTypeDB::bind_method(_MD("get_align"), &LineEdit::get_align); ObjectTypeDB::bind_method(_MD("get_align"), &LineEdit::get_align);

View file

@ -108,7 +108,9 @@ private:
void clear_internal(); void clear_internal();
void changed_internal(); void changed_internal();
#ifdef TOOLS_ENABLED
void _editor_settings_changed();
#endif
void _input_event(InputEvent p_event); void _input_event(InputEvent p_event);
void _notification(int p_what); void _notification(int p_what);