natiny_view_get_hovered

C
bool natiny_view_get_hovered(NatinyView view);

Returns whether the pointer is over a view or over one of its pickable descendants.

Parameters

Name Type Description
view NatinyView View handle

Returns

Type Description
bool true between this view's NATINY_VIEW_HOOK_MOUSE_ENTER and NATINY_VIEW_HOOK_MOUSE_LEAVE

Example

C
static void draw_button(NatinyView self, void* userdata) {
    float x, y, w, h;
    natiny_view_get_rect(self, &x, &y, &w, &h);
    natiny_render_set_color(natiny_view_get_hovered(self) ? HOVER : IDLE);
    natiny_render_rectangle(x, y, w, h);
}

Notes

  • While a view is pressed the hover does not change anywhere under that root, even when the pointer leaves: it catches up when the button is released. See natiny_view_set_hook.