From 0b47e63ba3598fd05fec941e0d0c72cf9234eddd Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 30 May 2026 13:36:48 +0200 Subject: [PATCH] Fix regression from 0a39d88221ece5d425af3c0a33c40049c5c61ec7 to display selected enum properly --- Source/Editor/GUI/ComboBox.cs | 11 ++++++++++- Source/Editor/GUI/EnumComboBox.cs | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Source/Editor/GUI/ComboBox.cs b/Source/Editor/GUI/ComboBox.cs index 06eabd1da..99be6a605 100644 --- a/Source/Editor/GUI/ComboBox.cs +++ b/Source/Editor/GUI/ComboBox.cs @@ -486,6 +486,15 @@ namespace FlaxEditor.GUI button.TooltipText = _tooltips[index]; } + /// + /// Gets the text for selected item(s). + /// + /// The display text. + protected virtual string GetSelectedText() + { + return _selectedIndices.Count == 1 ? (_selectedIndices[0] >= 0 && _selectedIndices[0] < _items.Count ? _items[_selectedIndices[0]] : "") : "Multiple Values"; + } + /// /// Creates the popup menu. /// @@ -554,7 +563,7 @@ namespace FlaxEditor.GUI // Check if has selected item if (_selectedIndices != null && _selectedIndices.Count > 0) { - string text = _selectedIndices.Count == 1 ? (_selectedIndices[0] >= 0 && _selectedIndices[0] < _items.Count ? _items[_selectedIndices[0]] : "") : "Multiple Values"; + string text = GetSelectedText(); // Draw text of the selected item float textScale = Height / DefaultHeight; diff --git a/Source/Editor/GUI/EnumComboBox.cs b/Source/Editor/GUI/EnumComboBox.cs index 67e538d39..a463f8b7c 100644 --- a/Source/Editor/GUI/EnumComboBox.cs +++ b/Source/Editor/GUI/EnumComboBox.cs @@ -112,7 +112,7 @@ namespace FlaxEditor.GUI for (int i = 0; i < _entries.Count; i++) { var e = _entries[i].Value; - if (e != 0 && (e & value) == e) + if ((e != 0 || value == 0) && (e & value) == e) { selection.Add(i); } @@ -294,6 +294,22 @@ namespace FlaxEditor.GUI button.CloseMenuOnClick = false; } + /// + protected override string GetSelectedText() + { + // If multiple values are selected then try to find an enum item that matches the mask value + if (_selectedIndices.Count > 1) + { + foreach (var e in _entries) + { + if (e.Value == Value) + return e.Name; + } + } + + return base.GetSelectedText(); + } + /// protected override void OnItemClicked(int index) {