pothi.love/0006-on.mouse_press

30 lines
690 B
Plaintext

on.mouse_press = function(x,y, mouse_button)
if Animating then return end
if Zoomed_out then
zoom_in(x,y)
return
end
if Cursor_node then
Cursor_node.show_cursor = nil
Cursor_node = nil
end
if mouse_press_consumed_by_any_button_handler(HUD, x,y, mouse_button) then
return
end
local node = on_text(x,y)
if node then
-- position cursor in node
Cursor_node = node
edit.mouse_press(node.editor, x,y, mouse_button)
return
end
local node = on_handle(x,y)
if node then
-- move node
Move = {xoff=App.mouse_x()-vx(node.x), yoff=App.mouse_y()-vy(node.y), node=node}
return
end
-- pan surface
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
end