diff options
author | Robert Lewicki <zguba44@gmail.com> | 2016-07-19 20:50:01 +0200 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2016-07-22 16:28:37 +0200 |
commit | b1df9e016cb8b7dac7499149f3f7d2a10575b133 (patch) | |
tree | c53e45ebd7f134ea1e72545c72d155abaee3ddb4 | |
parent | 3aeafcae04722dd6d6ff52632dec9f31239875e4 (diff) |
Fixed ItemList indexing bug while selecting items.
Also added functionality for unselecting items in itemlist while clicking in empty space.
Fixes #5772.
-rw-r--r-- | scene/gui/item_list.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 2f4f79904d..712e929745 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -461,7 +461,6 @@ void ItemList::_input_event(const InputEvent& p_event) { pos.y+=scroll_bar->get_val(); int closest = -1; - int closest_dist=0x7FFFFFFF; for(int i=0;i<items.size();i++) { @@ -474,12 +473,6 @@ void ItemList::_input_event(const InputEvent& p_event) { closest=i; break; } - - float dist = rc.distance_to(pos); - if (dist<closest_dist) { - closest=i; - closest_dist=dist; - } } if (closest!=-1) { @@ -546,6 +539,11 @@ void ItemList::_input_event(const InputEvent& p_event) { 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) { @@ -823,7 +821,7 @@ void ItemList::_notification(int p_what) { } if (shape_changed) { - + float max_column_width = 0; //1- compute item minimum sizes @@ -914,11 +912,11 @@ void ItemList::_notification(int p_what) { if (i<items.size()-1) separators.push_back(ofs.y+max_h+vseparation/2); - + for(int j=i;j>=0 && col>0;j--, col--) { items[j].rect_cache.size.y = max_h; } - + ofs.x=0; ofs.y+=max_h+vseparation; col=0; @@ -1386,4 +1384,3 @@ ItemList::ItemList() { ItemList::~ItemList() { } - |