bug feedback, m_ItemView.Click(); Repeated call

ub3132003

New member
the m_ItemView.Click() .call at ItemviewSlot.onPointClick and GridGeneric.ViewClicked.
m_ViewDrawer.Click(index);
When I click the slot, it causes two clicks this time.
 
Ah you are right... That's a bit tricky. You can have an ItemViewSlot with no Grid and have a Grid with no ItemViewSlot.
So both need to call ItemViewClick independently... but having both calls it twice.

I think I will override the ViewClicked function in ItemInfoGrid assuming that you will always use ItemViewSlots for those types of grids.


So in the GridGeneric class:
Code:
/// <summary>
        /// Click the box at the index.
        /// </summary>
        /// <param name="index">The index.</param>
        protected override void ViewClicked(int index)
        {
            m_ViewDrawer.Click(index);

            if (m_Elements.Count <= StartIndex + index) {
                NotifyEmptyClicked(index);
                return;
            }

            var selectedElements = GetElementAt(StartIndex + index);

            NotifyElementClicked(index, selectedElements);
        }

        /// <summary>
        /// Notifies that an element has been clicked in the grid.
        /// </summary>
        /// <param name="index">The index of the clicked element.</param>
        /// <param name="selectedElements">The clicked element of type T.</param>
        protected virtual void NotifyElementClicked(int index, T selectedElements)
        {
            OnElementClicked?.Invoke(selectedElements, index);
        }

        /// <summary>
        /// Notifies that an empty grid slot has been clicked.
        /// </summary>
        /// <param name="index">The index of the empty slot that was clicked.</param>
        protected virtual void NotifyEmptyClicked(int index)
        {
            OnEmptyClicked?.Invoke(index);
        }


and in the ItemInfoGrid class
Code:
/// <summary>
/// The inventory grid  UI.
/// </summary>
public class ItemInfoGrid : GridGeneric<ItemInfo>
{
    /// <summary>
    /// Click the box at the index.
    /// </summary>
    /// <param name="index">The index.</param>
    protected override void ViewClicked(int index)
    {
        if (m_Elements.Count <= StartIndex + index) {
            NotifyEmptyClicked(index);
            return;
        }
        var selectedElements = GetElementAt(StartIndex + index);
        NotifyElementClicked(index, selectedElements);
    }
}

Thanks for bringing this up :)
 
Back
Top