System clipboard access. No permission required.
Write
def handle_event("copy", _params, socket) do
Mob.Clipboard.put(socket, socket.assigns.text)
{:noreply, socket}
endRead
def handle_event("paste", _params, socket) do
case Mob.Clipboard.get(socket) do
{:clipboard, :ok, text} -> {:noreply, Mob.Socket.assign(socket, :field, text)}
{:clipboard, :empty} -> {:noreply, socket}
end
endget/1 dispatches to the main thread synchronously (same model as
safe_area/0) — fast enough to call from any callback.
Summary
Functions
Read the current clipboard text synchronously.
Write text to the system clipboard. Fire-and-forget; returns the socket.
Functions
@spec get(Mob.Socket.t()) :: {:clipboard, :ok, binary()} | {:clipboard, :empty}
Read the current clipboard text synchronously.
Returns {:clipboard, :ok, text} or {:clipboard, :empty}.
@spec put(Mob.Socket.t(), binary()) :: Mob.Socket.t()
Write text to the system clipboard. Fire-and-forget; returns the socket.