示例#1
0
        bool IInputListener.OnMousePressed(Vector2 mousePos)
        {
            if (_selection.IsDisabled() || _items.Count == 0)
            {
                return(false);
            }

            var lastSelectedItem = _selection.GetLastSelected();
            var index            = GetItemIndexUnderMousePosition(mousePos);

            index = Math.Max(0, index);
            index = Math.Min(_items.Count - 1, index);
            _selection.Choose(_items[index]);

            if (lastSelectedItem != _items[index] && OnChanged != null)
            {
                OnChanged(_items[index]);
            }

            return(true);
        }