You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-26 15:46:23 +00:00
Add column_title_pressed signal to Tree node
The Tree node column/table form is missing the ability to
capture column title clicks easily.
Adding this functionality will give us the ability to
create functions such as sort by column, which is a common
table manipulation ability in games/apps.
https://godotengine.org/qa/7699
(cherry picked from commit 7b00ad22b9)
This commit is contained in:
@@ -2180,6 +2180,26 @@ void Tree::_input_event(InputEvent p_event) {
|
|||||||
|
|
||||||
if (b.button_index == BUTTON_LEFT) {
|
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) {
|
if (single_select_defer) {
|
||||||
select_single_item(single_select_defer, root, single_select_defer_column);
|
select_single_item(single_select_defer, root, single_select_defer_column);
|
||||||
single_select_defer = NULL;
|
single_select_defer = NULL;
|
||||||
@@ -3408,6 +3428,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("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("custom_popup_edited", PropertyInfo(Variant::BOOL, "arrow_clicked")));
|
||||||
ADD_SIGNAL(MethodInfo("item_activated"));
|
ADD_SIGNAL(MethodInfo("item_activated"));
|
||||||
|
ADD_SIGNAL(MethodInfo("column_title_pressed", PropertyInfo(Variant::INT, "column")));
|
||||||
|
|
||||||
BIND_CONSTANT(SELECT_SINGLE);
|
BIND_CONSTANT(SELECT_SINGLE);
|
||||||
BIND_CONSTANT(SELECT_ROW);
|
BIND_CONSTANT(SELECT_ROW);
|
||||||
|
|||||||
Reference in New Issue
Block a user