// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using FlaxEngine; namespace FlaxEditor.CustomEditors.GUI { /// /// Custom property name label that fires mouse events for label. /// /// [HideInEditor] public class ClickablePropertyNameLabel : PropertyNameLabel { /// /// Mouse action delegate. /// /// The label. /// The mouse location. public delegate void MouseDelegate(ClickablePropertyNameLabel label, Float2 location); /// /// The mouse left button clicks on the label. /// public MouseDelegate MouseLeftClick; /// /// The mouse right button clicks on the label. /// public MouseDelegate MouseRightClick; /// /// The mouse left button double clicks on the label. /// public MouseDelegate MouseLeftDoubleClick; /// /// The mouse right button double clicks on the label. /// public MouseDelegate MouseRightDoubleClick; /// public ClickablePropertyNameLabel(string name) : base(name) { } /// public override bool OnMouseUp(Float2 location, MouseButton button) { // Fire events if (button == MouseButton.Left) { if (MouseLeftClick != null) { MouseLeftClick.Invoke(this, location); return true; } } else if (button == MouseButton.Right) { if (MouseRightClick != null) { MouseRightClick.Invoke(this, location); return true; } } return base.OnMouseUp(location, button); } /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { // Fire events if (button == MouseButton.Left) { if (MouseLeftDoubleClick != null) { MouseLeftDoubleClick.Invoke(this, location); return true; } } else if (button == MouseButton.Right) { if (MouseRightDoubleClick != null) { MouseRightDoubleClick.Invoke(this, location); return true; } } return base.OnMouseDoubleClick(location, button); } /// public override void OnDestroy() { // Unlink events MouseLeftClick = null; MouseRightClick = null; MouseLeftDoubleClick = null; MouseRightDoubleClick = null; base.OnDestroy(); } } }