DroppableWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A widget that defines a drop target region. When a draggable item is dragged over this region, the builder lambda receives a with the current drag-hover state so the content can render differently to indicate drop availability.
public sealed record DroppableWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<DroppableWidget>Inheritance
Object → Hex1bWidget → DroppableWidget
Implements
Constructors
DroppableWidget(Func<DroppableContext, Hex1bWidget>)
A widget that defines a drop target region. When a draggable item is dragged over this region, the builder lambda receives a with the current drag-hover state so the content can render differently to indicate drop availability.
Parameters:
Builder(Func<DroppableContext, Hex1bWidget>):
public DroppableWidget(Func<DroppableContext, Hex1bWidget> Builder)Properties
Builder
Returns: Func<DroppableContext, Hex1bWidget>
public Func<DroppableContext, Hex1bWidget> Builder { get; init; }Methods
Accept(Func<object, bool>)
Sets a predicate that determines whether this target accepts the given drag data. When a drag hovers over this target, the predicate is evaluated and the result is available via .
Parameters:
predicate(Func<Object, Boolean>):
Returns: DroppableWidget
public DroppableWidget Accept(Func<object, bool> predicate)OnDrop(Action<DropEventArgs>)
Sets a synchronous drop handler.
Parameters:
handler(Action<DropEventArgs>):
Returns: DroppableWidget
public DroppableWidget OnDrop(Action<DropEventArgs> handler)OnDrop(Func<DropEventArgs, Task>)
Sets an asynchronous drop handler.
Parameters:
handler(Func<DropEventArgs, Task>):
Returns: DroppableWidget
public DroppableWidget OnDrop(Func<DropEventArgs, Task> handler)OnDropTarget(Action<DropTargetEventArgs>)
Sets a synchronous handler for drops on specific insertion points.
Parameters:
handler(Action<DropTargetEventArgs>):
Returns: DroppableWidget
public DroppableWidget OnDropTarget(Action<DropTargetEventArgs> handler)OnDropTarget(Func<DropTargetEventArgs, Task>)
Sets an asynchronous handler for drops on specific insertion points.
Parameters:
handler(Func<DropTargetEventArgs, Task>):
Returns: DroppableWidget
public DroppableWidget OnDropTarget(Func<DropTargetEventArgs, Task> handler)Examples
ctx.Droppable(dc => [
dc.Text(dc.IsHoveredByDrag ? "Drop here!" : "Target area"),
])
.Accept(data => data is string s && s.EndsWith(".txt"))
.OnDrop(e => HandleDrop(e.DragData))