Client-local widget focus
Pointer targeting samples each player's aim once per
server tick, so hover styling drawn from it changes in 50 ms steps. A resource
pack can resolve hover itself. A client-synced entity reconstructs the viewer's
camera ray in Molang every frame and tests it against the control's committed
rectangle. Hover then changes on the client's next frame.
bedform/Spatial/Focus (Spatial.Focus from bedform) supplies the geometry
for that test and decides when it is safe. The module is pure. It starts
nothing and touches no native API.
BedformCanvas implements the client side in its widget_visual_* actors. See
Addon/BedformCanvas/Public/WidgetVisual.ts for the synced property contract.
WidgetDemo uses it for all of its shared controls. See
its actor notes.
Which rectangle a client may test
Focus.HitBox(items, control, part) returns the rectangle where the camera
alone decides hover, or undefined when the server must decide. part is
"Body" for a control's bounds or "Track" for a ScrollView's scrollbar track.
Focus.Isolated is the boolean form.
The server keeps hover when the result depends on the viewer or the scene:
- Policies. Access controllers, required items, disabled pointer input and
a non-positive
MaxDistancediffer per viewer. - Clipping. The part must lie wholly inside its ScrollView clip. A row scrolled partly out of view returns to the server.
- Overlap. No later painted item may overlap the part with positive area.
Shared edges are allowed. The control's own content is allowed inside its
bounds: Text labels, icon Images and any other descendant with nothing
interactive between it and the control, because the pointer routes those hits
to the control. A nested interactive descendant still returns
undefined. - Scrollbar tracks. A track along one full edge of the part is removed from
the rectangle, because the track wins there. Any other track overlap returns
undefined. A track is drawn over its own ScrollView's descendants, so they never contest the"Track"part.
Disabled controls remain eligible. Their disabled style takes precedence over hover on the client.
Describing the rectangle to an actor
Focus.RegionOf(view, box, anchor, reach) converts a hit rectangle to blocks
relative to the actor at anchor. It returns Width, Height, OffsetX and
OffsetY for the center in world X and Y, Depth for how far the actor sits in
front of the hit plane, and Reach. An actor need not sit at the rectangle's
center. For example, a Toggle's actor sits on its switch but tests the whole
control. Only north-facing Views are supported. Check them with
Focus.NorthFacing. RegionOf returns undefined for other orientations, for
an actor on or behind the plane, and for values beyond Focus.MaximumExtent
(32.5 blocks).
Focus.ReachOf(control, range) gives the hover distance. By default it is the
pointer's 64-block range, limited by the control's MaxDistance.
World occlusion
Molang cannot query blocks, so client hover would show through walls.
Focus.Samples(view, box) returns the rectangle's center and four inset
corners. A host can raycast from each viewer's eye to these points, for
example with Pointer.Obstruction. While any viewer in reach is blocked, the
host keeps that control on server-resolved hover.
What stays on the server
Hover is visual only. Activation, access admission, callbacks, pressed and checked state, and the pointer line still follow the tracker and router at tick rate. Shared actors show the same pressed state to every viewer. Private views need per-viewer rendering and keep server hover.