Repository: FlaxEngine/FlaxEngine
File: Source/Editor/Windows/ContentWindow.cs (C#)

Code before:
                    return;
                foreach (var item in ((ContextMenu)control).Items)
                {
                    if (item is ContextMenuButton button)
                        button.Checked = _buttonNameChecked == button.Text;
                }
            };

            return menu;
        }

        private void OnViewTypeButtonClicked(ContextMenuButton button)
        {
            View.ViewType = (ContentViewType)button.Tag;
        }

        private void OnFilterClicked(ContextMenuButton filterButton)
        {
            var i = (int)filterButton.Tag;
            _viewDropdown.OnClicked(i);
        }

        private void OnSortByButtonClicked(ContextMenuButton button)
        {
            _buttonNameChecked = button.Text;
            switch (button.Text)
            {
                case "Alphabetic Order": _sortType = SortType.AlphabeticOrder;
                    break;
                case "Alphabetic Reverse": _sortType = SortType.AlphabeticReverse;
                    break;
            }
            RefreshView(SelectedNode);
        }

        /// <summary>
        /// Shows popup dialog with UI to rename content item.
        /// </summary>
        /// <param name="item">The item to rename.</param>
        public void Rename(ContentItem item)
        {
            // Show element in the view
            Select(item, true);

            // Disable scrolling in content view
            if (_split.Panel2.VScrollBar != null)
                _split.Panel2.VScrollBar.ThumbEnabled = false;
            if (_split.Panel2.HScrollBar != null)
                _split.Panel2.HScrollBar.ThumbEnabled = false;

            // Show rename popup

Review comment (suggestion):
This could use `(SortType)button.Tag` instead of button text checking.

Code after:
                foreach (var item in ((ContextMenu)control).Items)
                {
                    if (item is ContextMenuButton button)
                        button.Checked = _sortType == (SortType)button.Tag;
                }
            };

            return menu;
        }

        private void OnViewTypeButtonClicked(ContextMenuButton button)
        {
            View.ViewType = (ContentViewType)button.Tag;
        }

        private void OnFilterClicked(ContextMenuButton filterButton)
        {
            var i = (int)filterButton.Tag;
            _viewDropdown.OnClicked(i);
        }

        private void OnSortByButtonClicked(ContextMenuButton button)
        {
            switch ((SortType)button.Tag)
            {
                case SortType.AlphabeticOrder: _sortType = SortType.AlphabeticOrder;
                    break;
                case SortType.AlphabeticReverse: _sortType = SortType.AlphabeticReverse;
                    break;
            }
            RefreshView(SelectedNode);
        }

        /// <summary>
        /// Shows popup dialog with UI to rename content item.
        /// </summary>
        /// <param name="item">The item to rename.</param>
        public void Rename(ContentItem item)
        {
            // Show element in the view
            Select(item, true);

            // Disable scrolling in content view
            if (_split.Panel2.VScrollBar != null)
                _split.Panel2.VScrollBar.ThumbEnabled = false;
            if (_split.Panel2.HScrollBar != null)
                _split.Panel2.HScrollBar.ThumbEnabled = false;

            // Show rename popup
            var popup = RenamePopup.Show(item, item.TextRectangle, item.ShortName, true);
            popup.Tag = item;