Button.cs 840 B

123456789101112131415161718192021222324252627282930
  1. using PixiEditor.Extensions.CommonApi.LayoutBuilding;
  2. using PixiEditor.Extensions.CommonApi.LayoutBuilding.Events;
  3. namespace PixiEditor.Extensions.Wasm.Api.LayoutBuilding;
  4. public class Button : SingleChildLayoutElement
  5. {
  6. public event ElementEventHandler Click
  7. {
  8. add => AddEvent(nameof(Click), value);
  9. remove => RemoveEvent(nameof(Click), value);
  10. }
  11. public Button(ILayoutElement<CompiledControl> child = null, ElementEventHandler onClick = null)
  12. {
  13. Child = child;
  14. if (onClick != null)
  15. Click += onClick;
  16. }
  17. public override CompiledControl Build()
  18. {
  19. CompiledControl button = new CompiledControl(UniqueId, "Button");
  20. if (Child != null)
  21. button.AddChild(Child.Build());
  22. BuildPendingEvents(button);
  23. return button;
  24. }
  25. }