Class Ref<T>
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Reference holder for an element or imperative handle.
Receives a VisualElement-derived type via refCallback:, and can also hold any handle
interface exposed by UseImperativeHandle.
public sealed class Ref<T> where T : class
Type Parameters
TType being referenced. Only constrained to class; not restricted to VisualElement.
- Inheritance
-
objectRef<T>
Constructors
Properties
- Current
Referenced target. null before mount and after unmount. Can be overwritten at any time via Set(T?).
Methods
- Set(T?)
Directly overwrites the referenced target. Pass
Set(null)to clear the reference (for example during cleanup).
- SetElement(VisualElement)
Callback ref setter. Used as
V.Button(refCallback: _ref.SetElement). Stores the element into Current; the returnedActionis the cleanup that resetsCurrent = nullon detach. For T values not derived from VisualElement,element as Tis always null, so this is primarily used for Element-node refs.