natiny.view.get_hovered
Lua
natiny.view.get_hovered(view) -> hovered
Returns whether the pointer is over a view or over one of its pickable
descendants.
Parameters
| Name |
Type |
Description |
view |
number |
View handle |
Returns
| Type |
Description |
boolean |
true between this view's natiny.view.HOOK_MOUSE_ENTER and natiny.view.HOOK_MOUSE_LEAVE |
Example
Lua
natiny.view.set_hook(button, natiny.view.HOOK_DRAW, function(self)
natiny.render.set_color(natiny.view.get_hovered(self) and HOVER or IDLE)
natiny.render.rectangle(natiny.view.get_rect(self))
end)
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.