summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorFranklin Sobrinho <franklin_gs@hotmail.com>2016-01-21 13:03:06 -0300
committerFranklin Sobrinho <franklin_gs@hotmail.com>2016-01-21 13:03:06 -0300
commit06cafeac0a15051e1ba2733989f0a70ae59d496f (patch)
tree19003fa5c892d005551e41a6b8484591f7c7b5c7 /scene/gui
parentfcae3fb3bab25b588921e84ce43924c830b18dc5 (diff)
Tree and PropertyEditor confirm value change on focus loss
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/tree.cpp25
-rw-r--r--scene/gui/tree.h5
2 files changed, 29 insertions, 1 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 8d28180490..799d2842bb 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1719,6 +1719,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
void Tree::text_editor_enter(String p_text) {
+ text_changed=false;
text_editor->hide();
value_editor->hide();
@@ -1757,6 +1758,22 @@ void Tree::text_editor_enter(String p_text) {
}
+void Tree::text_editor_changed(String p_text) {
+
+ text_changed=true;
+}
+
+void Tree::text_editor_hide() {
+
+ if (!text_changed)
+ return;
+
+ if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE))
+ return;
+
+ text_editor_enter(text_editor->get_text());
+}
+
void Tree::value_editor_changed(double p_value) {
if (updating_value_editor) {
@@ -2350,6 +2367,8 @@ bool Tree::edit_selected() {
} else if (c.mode==TreeItem::CELL_MODE_STRING || c.mode==TreeItem::CELL_MODE_RANGE) {
+ text_changed=false;
+
Point2i textedpos=get_global_pos() + rect.pos;
text_editor->set_pos( textedpos );
text_editor->set_size( rect.size);
@@ -3185,6 +3204,8 @@ void Tree::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event);
ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
+ ObjectTypeDB::bind_method(_MD("_text_editor_changed"),&Tree::text_editor_changed);
+ ObjectTypeDB::bind_method(_MD("_text_editor_hide"),&Tree::text_editor_hide);
ObjectTypeDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed);
ObjectTypeDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved);
@@ -3283,6 +3304,8 @@ Tree::Tree() {
h_scroll->connect("value_changed", this,"_scroll_moved");
v_scroll->connect("value_changed", this,"_scroll_moved");
text_editor->connect("text_entered", this,"_text_editor_enter");
+ text_editor->connect("text_changed",this,"_text_editor_changed");
+ text_editor->connect("hide",this,"_text_editor_hide");
popup_menu->connect("item_pressed", this,"_popup_select");
value_editor->connect("value_changed", this,"_value_editor_changed");
@@ -3316,6 +3339,8 @@ Tree::Tree() {
hide_folding=false;
+ text_changed=false;
+
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 54e6a9c6b9..2562e6aaef 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -271,7 +271,6 @@ friend class TreeItem;
bool range_drag_enabled;
Vector2 range_drag_capture_pos;
-
//TreeItem *cursor_item;
//int cursor_column;
@@ -314,6 +313,8 @@ friend class TreeItem;
void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL);
int propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_doubleclick,TreeItem *p_item,int p_button,const InputModifierState& p_mod);
void text_editor_enter(String p_text);
+ void text_editor_changed(String p_text);
+ void text_editor_hide();
void value_editor_changed(double p_value);
void popup_select(int p_option);
@@ -418,6 +419,8 @@ friend class TreeItem;
bool hide_folding;
+ bool text_changed;
+
protected:
static void _bind_methods();