Fix regression from 0a39d88221 to display selected enum properly
This commit is contained in:
@@ -486,6 +486,15 @@ namespace FlaxEditor.GUI
|
||||
button.TooltipText = _tooltips[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text for selected item(s).
|
||||
/// </summary>
|
||||
/// <returns>The display text.</returns>
|
||||
protected virtual string GetSelectedText()
|
||||
{
|
||||
return _selectedIndices.Count == 1 ? (_selectedIndices[0] >= 0 && _selectedIndices[0] < _items.Count ? _items[_selectedIndices[0]] : "") : "Multiple Values";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the popup menu.
|
||||
/// </summary>
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnItemClicked(int index)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user