/// <summary>
        /// Populates and displays a custom popup.
        /// </summary>
        /// <example>
        /// <code language="csharp"><![CDATA[
        /// public static TValue MyCustomPopup<TValue>(
        ///     Rect position,
        ///     GUIContent valueLabel,
        ///     TValue value,
        ///     CustomPopupPopulateDelegate<TValue> populatePopupDelegate)
        /// {
        ///     int popupControlID = GUIUtility.GetControlID(FocusType.Passive);
        ///     if (EditorGUI.DropdownButton(position, valueLabel, FocusType.Keyboard)) {
        ///         CustomPopupGUI.DisplayPopup(position, popupControlID, value, populatePopupDelegate);
        ///     }
        ///     return CustomPopupGUI.HandlePopupValueSelection(popupControlID, value);
        /// }
        /// ]]></code>
        /// </example>
        /// <typeparam name="TValue">The type of value that is being selected.</typeparam>
        /// <param name="position">Absolute position of control on the GUI.</param>
        /// <param name="popupControlID">Control ID of the popup.</param>
        /// <param name="value">Current value selection.</param>
        /// <param name="populatePopupDelegate">Delegate that populates popup menu.</param>
        /// <seealso cref="HandlePopupValueSelection{TValue}(int, TValue)"/>
        public static void DisplayPopup <TValue>(Rect position, int popupControlID, TValue value, CustomPopupPopulateDelegate <TValue> populatePopupDelegate)
        {
            SetActivePopupControl(popupControlID, value);

            var popup   = new CustomPopup <TValue>();
            var context = new PopupContext <TValue>(popup, value);

            populatePopupDelegate.Invoke(context);

            popup.ShowAsDropdown(position);
        }
    private void OnItemSelected(Item item, PopupContext context)
    {
        _selectedItem = item;

        var pos = Input.mousePosition;

        //todo check if window is near edge of game area
        //todo possibly make window draggable so player can adjust if needed
        gameObject.transform.position = new Vector2(pos.x + 90f, pos.y + 80f);

        LoadButtons(context == PopupContext.DroppedItem ? _droppedItemButtons : _menuItemButtons);

        gameObject.SetActive(true);
        EquipmentSlotPanel.SetActive(false);
        GameManager.Instance.AddActiveWindow(gameObject);
    }