Dragging
See the DraggingDemo class.
Gui.InputVector2("offset", ref offset);
// Allocate a 100x100 rectangle for the dragging area.
var rect = Ctx.AllocateRect(100, 100);
// Render a box to visualize the area.
Gui.Box(rect);
// Define an interactive area for detecting user interaction.
Gui.NextRect(rect).InteractiveArea();
// If the interactive area is active, update the offset based on pointer movement.
if (Ctx.IsWidgetActive<InteractiveAreaWidget>())
{
offset += Input.PointerDeltaPos;
}
// Prevents drawing outside the rect.
using (Ctx.PushClip(rect))
{
// Render a sprite inside the dragging area, offset by the user interaction.
Gui.NextRect(new Rect(rect.x + offset.x, rect.y + offset.y, 20, 20))
.Image(Properties.SquareSprite);
}