2023-01-22 05:38:14 +00:00
|
|
|
on.mouse_press = function(x,y, mouse_button)
|
2023-06-22 06:22:13 +01:00
|
|
|
if Cursor_node then
|
|
|
|
Cursor_node.show_cursor = nil
|
|
|
|
Cursor_node = nil
|
|
|
|
end
|
2023-06-22 06:48:47 +01:00
|
|
|
-- buttons at the HUD level can use the buttons.lua abstraction
|
2023-06-22 06:22:13 +01:00
|
|
|
if mouse_press_consumed_by_any_button_handler(HUD, x,y, mouse_button) then
|
2023-01-22 05:38:14 +00:00
|
|
|
return
|
|
|
|
end
|
2023-06-22 06:48:47 +01:00
|
|
|
-- 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
|
2023-06-22 06:22:13 +01:00
|
|
|
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
|
2023-01-22 05:38:14 +00:00
|
|
|
end
|
2023-06-22 06:22:13 +01:00
|
|
|
-- pan surface
|
|
|
|
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
|
2023-06-18 21:04:18 +01:00
|
|
|
end
|