natiny.view.set_offset
natiny.view.set_offset(view, x, y)
Moves a view and everything in it from where its parent placed it, without moving anything else.
Parameters
| Name | Type | Description |
|---|---|---|
view |
number |
View handle |
x |
number |
Distance to the right, in drawing units; negative moves left |
y |
number |
Distance down, in drawing units; negative moves up |
Example
-- a window dragged by its title bar
natiny.view.set_hook(title, natiny.view.HOOK_MOUSE_MOVE, function(self)
if natiny.view.get_pressed(self) then
drag_x = drag_x + natiny.input.get_mouse_x_speed()
drag_y = drag_y + natiny.input.get_mouse_y_speed()
natiny.view.set_offset(window, drag_x, drag_y)
end
end)