Skip to content

Commit

Permalink
Merge pull request #8796 from yanorax/treecolumn_title_pressed
Browse files Browse the repository at this point in the history
Add column_title_pressed signal to Tree node
  • Loading branch information
akien-mga authored May 18, 2017
2 parents f85cad4 + 7b00ad2 commit a75623f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a75623f

Please sign in to comment.