Add RMB and MMB actions to Type Editor control

This commit is contained in:
2026-09-02 23:08:23 +02:00
parent cb513e9271
commit c3a1312285
@@ -32,7 +32,7 @@ namespace FlaxEditor.CustomEditors.Editors
private DragHandlers _dragHandlers;
/// <summary>
/// Gets or sets the allowed type (given type and all sub classes). Must be <see cref="System.Type"/> type of any subclass.
/// Gets or sets the allowed type (given type and all subclasses). Must be <see cref="System.Type"/> type of any subclass.
/// </summary>
public ScriptType Type
{
@@ -209,7 +209,6 @@ namespace FlaxEditor.CustomEditors.Editors
/// <inheritdoc />
public override bool OnMouseUp(Float2 location, MouseButton button)
{
// Cache data
bool isSelected = _value != ScriptType.Null;
var frameRect = new Rectangle(0, 0, Width - 16, 16);
if (isSelected && _type == ScriptType.Null)
@@ -220,11 +219,30 @@ namespace FlaxEditor.CustomEditors.Editors
// Deselect
if (_value && button1Rect.Contains(ref location) && _type == ScriptType.Null)
{
Focus();
Value = ScriptType.Null;
return true;
}
// Picker dropdown menu
if ((isSelected && _type == ScriptType.Null ? button2Rect : button1Rect).Contains(ref location))
{
ShowDropDownMenu();
return true;
}
// Clear value with MMB or show picker with RMB
if (button == MouseButton.Middle)
{
Focus();
Value = ScriptType.Null;
return true;
}
if (button == MouseButton.Right)
{
ShowDropDownMenu();
}
return base.OnMouseUp(location, button);
}