Fix culture info editor picker to show under button

#3387
This commit is contained in:
Wojtek Figat
2025-04-16 09:39:24 +02:00
parent c30e31bd65
commit 45f202fdf7

View File

@@ -27,7 +27,7 @@ namespace FlaxEditor.CustomEditors.Editors
public override void Initialize(LayoutElementsContainer layout)
{
_label = layout.ClickableLabel(GetName(Culture)).CustomControl;
_label.RightClick += ShowPicker;
_label.RightClick += () => CreatePicker(Culture, OnValueChanged).Show(_label, new Float2(0, _label.Height));
var button = new Button
{
Width = 16.0f,
@@ -36,7 +36,7 @@ namespace FlaxEditor.CustomEditors.Editors
Parent = _label,
};
button.SetAnchorPreset(AnchorPresets.MiddleRight, false, true);
button.Clicked += ShowPicker;
button.ButtonClicked += b => CreatePicker(Culture, OnValueChanged).Show(b, new Float2(0, b.Height));
}
/// <inheritdoc />
@@ -74,6 +74,11 @@ namespace FlaxEditor.CustomEditors.Editors
}
}
private void OnValueChanged(CultureInfo value)
{
Culture = value;
}
private class CultureInfoComparer : IComparer<CultureInfo>
{
public int Compare(CultureInfo a, CultureInfo b)
@@ -82,12 +87,6 @@ namespace FlaxEditor.CustomEditors.Editors
}
}
private void ShowPicker()
{
var menu = CreatePicker(Culture, value => { Culture = value; });
menu.Show(_label, new Float2(0, _label.Height));
}
internal static ContextMenuBase CreatePicker(CultureInfo value, Action<CultureInfo> changed)
{
var menu = Utilities.Utils.CreateSearchPopup(out var searchBox, out var tree);