Fixed ItemList indexing bug while selecting items.
Also added functionality for unselecting items in itemlist while clicking in empty space. Fixes #5772.
This commit is contained in:
parent
3aeafcae04
commit
b1df9e016c
1 changed files with 8 additions and 11 deletions
|
@ -461,7 +461,6 @@ void ItemList::_input_event(const InputEvent& p_event) {
|
||||||
pos.y+=scroll_bar->get_val();
|
pos.y+=scroll_bar->get_val();
|
||||||
|
|
||||||
int closest = -1;
|
int closest = -1;
|
||||||
int closest_dist=0x7FFFFFFF;
|
|
||||||
|
|
||||||
for(int i=0;i<items.size();i++) {
|
for(int i=0;i<items.size();i++) {
|
||||||
|
|
||||||
|
@ -474,12 +473,6 @@ void ItemList::_input_event(const InputEvent& p_event) {
|
||||||
closest=i;
|
closest=i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dist = rc.distance_to(pos);
|
|
||||||
if (dist<closest_dist) {
|
|
||||||
closest=i;
|
|
||||||
closest_dist=dist;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closest!=-1) {
|
if (closest!=-1) {
|
||||||
|
@ -546,6 +539,11 @@ void ItemList::_input_event(const InputEvent& p_event) {
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
Vector<int> sItems = get_selected_items();
|
||||||
|
for(int i = 0; i < sItems.size(); i++) {
|
||||||
|
unselect(sItems[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
|
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
|
||||||
|
@ -823,7 +821,7 @@ void ItemList::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shape_changed) {
|
if (shape_changed) {
|
||||||
|
|
||||||
float max_column_width = 0;
|
float max_column_width = 0;
|
||||||
|
|
||||||
//1- compute item minimum sizes
|
//1- compute item minimum sizes
|
||||||
|
@ -914,11 +912,11 @@ void ItemList::_notification(int p_what) {
|
||||||
|
|
||||||
if (i<items.size()-1)
|
if (i<items.size()-1)
|
||||||
separators.push_back(ofs.y+max_h+vseparation/2);
|
separators.push_back(ofs.y+max_h+vseparation/2);
|
||||||
|
|
||||||
for(int j=i;j>=0 && col>0;j--, col--) {
|
for(int j=i;j>=0 && col>0;j--, col--) {
|
||||||
items[j].rect_cache.size.y = max_h;
|
items[j].rect_cache.size.y = max_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
ofs.x=0;
|
ofs.x=0;
|
||||||
ofs.y+=max_h+vseparation;
|
ofs.y+=max_h+vseparation;
|
||||||
col=0;
|
col=0;
|
||||||
|
@ -1386,4 +1384,3 @@ ItemList::ItemList() {
|
||||||
ItemList::~ItemList() {
|
ItemList::~ItemList() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue