summaryrefslogtreecommitdiff
path: root/scene/gui/item_list.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/item_list.cpp')
-rw-r--r--scene/gui/item_list.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 372baeadae..d367a8d281 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -309,12 +309,6 @@ void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon) {
shape_changed = true;
}
-Ref<Texture2D> ItemList::get_item_tag_icon(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>());
-
- return items[p_idx].tag_icon;
-}
-
void ItemList::set_item_selectable(int p_idx, bool p_selectable) {
if (p_idx < 0) {
p_idx += get_item_count();
@@ -807,8 +801,9 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) {
search_string = ""; //any mousepress cancels
for (int i = 4; i > 0; i--) {
- if (current - current_columns * i >= 0 && CAN_SELECT(current - current_columns * i)) {
- set_current(current - current_columns * i);
+ int index = current - current_columns * i;
+ if (index >= 0 && index < items.size() && CAN_SELECT(index)) {
+ set_current(index);
ensure_current_is_visible();
if (select_mode == SELECT_SINGLE) {
emit_signal(SNAME("item_selected"), current);
@@ -821,8 +816,9 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) {
search_string = ""; //any mousepress cancels
for (int i = 4; i > 0; i--) {
- if (current + current_columns * i < items.size() && CAN_SELECT(current + current_columns * i)) {
- set_current(current + current_columns * i);
+ int index = current + current_columns * i;
+ if (index >= 0 && index < items.size() && CAN_SELECT(index)) {
+ set_current(index);
ensure_current_is_visible();
if (select_mode == SELECT_SINGLE) {
emit_signal(SNAME("item_selected"), current);
@@ -838,7 +834,7 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) {
if (current % current_columns != 0) {
int current_row = current / current_columns;
int next = current - 1;
- while (!CAN_SELECT(next)) {
+ while (next >= 0 && !CAN_SELECT(next)) {
next = next - 1;
}
if (next < 0 || !IS_SAME_ROW(next, current_row)) {
@@ -858,7 +854,7 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) {
if (current % current_columns != (current_columns - 1) && current + 1 < items.size()) {
int current_row = current / current_columns;
int next = current + 1;
- while (!CAN_SELECT(next)) {
+ while (next < items.size() && !CAN_SELECT(next)) {
next = next + 1;
}
if (items.size() <= next || !IS_SAME_ROW(next, current_row)) {