summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2016-06-19 16:11:16 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2016-06-19 16:11:16 +0100
commit8cbd0b9ae34f893683bb650813320cfe9d1b3d78 (patch)
tree10e848417c25af980555d6497d0a6f6c0eb79ebc
parent37d1bf4d53c9e057fa344d37ce208874bf319268 (diff)
Text Edit no longer draws caret on focus loss
-rw-r--r--scene/gui/text_edit.cpp15
-rw-r--r--scene/gui/text_edit.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index c08247095a..8c928513f3 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -417,8 +417,22 @@ void TextEdit::_notification(int p_what) {
_update_caches();
} break;
+ case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ window_has_focus = true;
+ draw_caret = true;
+ update();
+ } break;
+ case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ window_has_focus = false;
+ draw_caret = false;
+ update();
+ } break;
case NOTIFICATION_DRAW: {
+ if ((!has_focus() && !menu->has_focus()) || !window_has_focus) {
+ draw_caret = false;
+ }
+
if (draw_breakpoint_gutter) {
breakpoint_gutter_width = (get_row_height() * 55) / 100;
cache.breakpoint_gutter_width = breakpoint_gutter_width;
@@ -4518,6 +4532,7 @@ TextEdit::TextEdit() {
brace_matching_enabled=false;
auto_indent=false;
insert_mode = false;
+ window_has_focus=true;
menu = memnew( PopupMenu );
add_child(menu);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 22f024c491..f01e6de1c9 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -217,6 +217,7 @@ class TextEdit : public Control {
Timer *caret_blink_timer;
bool caret_blink_enabled;
bool draw_caret;
+ bool window_has_focus;
bool setting_row;
bool wrap;