Fix detection of selected item
If there is no item selected, it should return -1, and not zero. This way makes the function return if the first item of the array is selected, skipping the treatment of this case.
If there is no item selected, it should return -1, and not zero. This way makes the function return if the first item of the array is selected, skipping the treatment of this case.