summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-05-18 19:06:25 +0200
committerGitHub <noreply@github.com>2017-05-18 19:06:25 +0200
commita75623f436c215e107ede321afa08a1897552deb (patch)
tree9f67cf574ad832ae073aadccac8872294bf9d127 /scene
parentf85cad4fec7c53d5b201956b3813b6aeb9b56fc6 (diff)
parent7b00ad22b94bd3f6194b25457f83d6240493217a (diff)
Merge pull request #8796 from yanorax/treecolumn_title_pressed
Add column_title_pressed signal to Tree node
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/tree.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 67c97c2e52..f77b160f57 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2214,6 +2214,26 @@ void Tree::_gui_input(InputEvent p_event) {
if (b.button_index == BUTTON_LEFT) {
+ Ref<StyleBox> bg = cache.bg;
+
+ Point2 pos = Point2(b.x, b.y) - bg->get_offset();
+ if (show_column_titles) {
+ pos.y -= _get_title_button_height();
+
+ if (pos.y < 0) {
+ pos.x += cache.offset.x;
+ int len = 0;
+ for (int i = 0; i < columns.size(); i++) {
+
+ len += get_column_width(i);
+ if (pos.x < len) {
+ emit_signal("column_title_pressed", i);
+ break;
+ }
+ }
+ }
+ }
+
if (single_select_defer) {
select_single_item(single_select_defer, root, single_select_defer_column);
single_select_defer = NULL;
@@ -3456,6 +3476,7 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::OBJECT, "item"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("custom_popup_edited", PropertyInfo(Variant::BOOL, "arrow_clicked")));
ADD_SIGNAL(MethodInfo("item_activated"));
+ ADD_SIGNAL(MethodInfo("column_title_pressed", PropertyInfo(Variant::INT, "column")));
BIND_CONSTANT(SELECT_SINGLE);
BIND_CONSTANT(SELECT_ROW);