Skip to main content

request_draw

Function request_draw 

Source
pub fn request_draw()
Expand description

Request that the host schedule another draw as soon as possible.

This is the right default for every widget state mutation that affects visual output. Calling it from inside an on_event handler advances invalidation_epoch; dispatch_event reads that epoch before/after delivery and automatically calls mark_dirty up the ancestor path when it sees a bump — so a retained ancestor’s backbuffer cache invalidates without the widget needing to know about that ancestor at all.

Without the epoch bump, a Widget::on_event that returns Ignored (the common case for MouseMove) leaves the ancestor cache thinking “nothing changed”, and the next frame composites a stale bitmap. Hover effects, focus rings, and any other appearance change driven by event state ALL need this hook.

Reach for request_draw_without_invalidation only when you’re certain no retained widget’s content changed — overlays, position-only translations, and similar. When in doubt, use request_draw.