Table of Contents

Class CustomElement

Namespace
SharpConsoleUI.Panel
Assembly
SharpConsoleUI.dll

A panel element with user-provided render and click callbacks.

public class CustomElement : PanelElement, IPanelElement
Inheritance
CustomElement
Implements
Inherited Members
Extension Methods

Constructors

CustomElement(string, int?, int)

Initializes a new CustomElement.

public CustomElement(string name, int? fixedWidth = null, int flexGrow = 0)

Parameters

name string

The element name.

fixedWidth int?

Optional fixed width.

flexGrow int

Optional flex grow factor.

Properties

ClickHandler

Gets or sets the click handler.

public Action? ClickHandler { get; set; }

Property Value

Action

FixedWidth

Gets the fixed width of this element, or null if it uses MeasureWidth() or flex sizing.

public override int? FixedWidth { get; }

Property Value

int?

FlexGrow

Gets the flex grow factor. 0 = fixed sizing, >0 = flex proportional to other flex elements.

public override int FlexGrow { get; }

Property Value

int

RenderCallback

Gets or sets the render callback.

public Action<CharacterBuffer, int, int, int, Color, Color>? RenderCallback { get; set; }

Property Value

Action<CharacterBuffer, int, int, int, Color, Color>

Methods

ProcessMouseEvent(MouseEventArgs, int, int)

Processes a mouse event that occurred within this element's bounds.

public override bool ProcessMouseEvent(MouseEventArgs args, int elementX, int elementWidth)

Parameters

args MouseEventArgs

The mouse event arguments.

elementX int

The x position of this element on screen.

elementWidth int

The allocated width of this element.

Returns

bool

True if the event was handled.

Render(CharacterBuffer, int, int, int, Color, Color)

Renders the element into the character buffer at the specified position.

public override void Render(CharacterBuffer buffer, int x, int y, int width, Color fg, Color bg)

Parameters

buffer CharacterBuffer

The character buffer to render into.

x int

The x position to render at.

y int

The y position to render at.

width int

The allocated width for this element.

fg Color

The default foreground color.

bg Color

The default background color.