Files
sbox-public/engine/Sandbox.Engine/Systems/UI/Panel/Event/PanelEvent.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

42 lines
1.2 KiB
C#

namespace Sandbox.UI;
/// <summary>
/// Base <see cref="Panel"/> event.<br/>
/// See <see cref="Panel.CreateEvent(PanelEvent)"/>.
/// </summary>
public class PanelEvent
{
public string Name { get; init; }
public object Value { get; set; }
public float Time { get; set; }
public string Button { get; set; }
/// <summary>
/// The panel on which the event is being called. For example, if you have a button with a label.. when the
/// button gets clicked the actual click event might come from the label. When the event is called on the
/// label, This will be the label. When the event propagates up to the button This will be the button - but
/// Target will be the label. This is mainly of use with Razor callbacks, where you want to get the actual
/// panel that created the event.
/// </summary>
public Panel This { get; set; }
public Panel Target { get; set; }
internal bool Propagate = true;
public PanelEvent( string eventName, Panel active = null )
{
Name = eventName;
Target = active;
}
public bool Is( string name )
{
return string.Equals( name, Name, System.StringComparison.OrdinalIgnoreCase );
}
public void StopPropagation()
{
Propagate = false;
}
}