pothi.love/0006-on.mouse_press

31 lines
854 B
Plaintext
Raw Normal View History

on.mouse_press = function(x,y, mouse_button)
if Cursor_node then
Cursor_node.show_cursor = nil
Cursor_node = nil
end
-- buttons at the HUD level can use the buttons.lua abstraction
if mouse_press_consumed_by_any_button_handler(HUD, x,y, mouse_button) then
return
end
-- other buttons need manual handling
if Global_state.thread == nil then
-- we're rendering the file picker
-- compute_layout reuses nodes and so it fills in x,y for us
for _,button in ipairs(Global_state.file_picker) do
if in_rect(button, x,y) then
open_thread(button.data[1].data)
A()
break
end
end
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
-- pan surface
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
end