PastableWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A container widget that intercepts bracketed paste events for all descendants. When paste data arrives and no child handles it, the receives the for streaming processing.
public sealed record PastableWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<PastableWidget>Inheritance
Object → Hex1bWidget → PastableWidget
Implements
Constructors
PastableWidget(Hex1bWidget)
A container widget that intercepts bracketed paste events for all descendants. When paste data arrives and no child handles it, the receives the for streaming processing.
Parameters:
Child(Hex1bWidget):
public PastableWidget(Hex1bWidget Child)Properties
Child
Returns: Hex1bWidget
public Hex1bWidget Child { get; init; }Methods
OnPaste(Action<PasteEventArgs>)
Sets the async paste handler using a synchronous action.
Parameters:
handler(Action<PasteEventArgs>):
Returns: PastableWidget
public PastableWidget OnPaste(Action<PasteEventArgs> handler)OnPaste(Func<PasteEventArgs, Task>)
Sets the async paste handler that receives streaming paste data.
Parameters:
handler(Func<PasteEventArgs, Task>):
Returns: PastableWidget
public PastableWidget OnPaste(Func<PasteEventArgs, Task> handler)WithMaxSize(int)
Sets the maximum paste size in characters. If exceeded, the paste is auto-cancelled.
Parameters:
maxCharacters(Int32):
Returns: PastableWidget
public PastableWidget WithMaxSize(int maxCharacters)WithTimeout(TimeSpan)
Sets a timeout for the paste operation. If exceeded, the paste is auto-cancelled.
Parameters:
timeout(TimeSpan):
Returns: PastableWidget
public PastableWidget WithTimeout(TimeSpan timeout)Examples
ctx.Pastable(
child: ctx.VStack(v => [
v.Text("Drop zone"),
v.TextBlock($"Received: {bytesReceived} bytes"),
]),
onPaste: async paste =>
{
await foreach (var chunk in paste.ReadChunksAsync())
{
bytesReceived += chunk.Length;
}
}
)