diff options
author | Juan Linietsky <reduz@Juans-MBP.fibertel.com.ar> | 2016-05-04 17:41:58 -0300 |
---|---|---|
committer | Juan Linietsky <reduz@Juans-MBP.fibertel.com.ar> | 2016-05-04 17:41:58 -0300 |
commit | f909634832a72cfc669fd1b6281c8a960ea3d40f (patch) | |
tree | a7698fab785b85ef029fcbbc96fcf391e6b91319 /scene/gui | |
parent | 8043135e0d34b59d82a6ac82d31cc0193f7faacf (diff) |
-make sure single select after multi select works better
-fixed some warnings for OSX
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/item_list.cpp | 23 | ||||
-rw-r--r-- | scene/gui/item_list.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 171dd94bfa..449e901876 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -297,6 +297,7 @@ void ItemList::remove_item(int p_idx){ items.remove(p_idx); update(); shape_changed=true; + defer_select_single=-1; } @@ -307,6 +308,7 @@ void ItemList::clear(){ current=-1; ensure_selected_visible=false; update(); + defer_select_single=-1; } @@ -392,6 +394,20 @@ Size2 ItemList::Item::get_icon_size() const { } void ItemList::_input_event(const InputEvent& p_event) { + + if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_MOTION) { + defer_select_single=-1; + return; + } + if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && !p_event.mouse_button.pressed) { + + select(defer_select_single,true); + + emit_signal("multi_selected",defer_select_single,true); + defer_select_single=-1; + return; + } + if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && p_event.mouse_button.pressed) { const InputEventMouseButton &mb = p_event.mouse_button; @@ -445,7 +461,13 @@ void ItemList::_input_event(const InputEvent& p_event) { emit_signal("multi_selected",i,true); } } else { + + if (!mb.mod.command && select_mode==SELECT_MULTI && items[i].selectable && items[i].selected) { + defer_select_single=i; + return; + } bool selected = !items[i].selected; + select(i,select_mode==SELECT_SINGLE || !mb.mod.command); if (selected) { if (select_mode==SELECT_SINGLE) { @@ -1186,6 +1208,7 @@ ItemList::ItemList() { current_columns=1; search_time_msec=0; ensure_selected_visible=false; + defer_select_single=-1; } diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index 2c3f8a5a01..5aec946686 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -61,6 +61,8 @@ private: int max_columns; Size2 min_icon_size; + int defer_select_single; + void _scroll_changed(double); void _input_event(const InputEvent& p_event); protected: |