click on file picker to open thread

There's one remaining issue: the DOM is changing between mouse press and
mouse release, which is confusing the select handler.

Options:
  * some sort of hacky thing to ignore the first mouse release
  * put the file picker handlers on mouse release rather than mouse
    press

There's some precedent for the latter option even if it might get
confusing in the presence of drag operations. But that seems confusing
either way. Just be consistent.
This commit is contained in:
Kartik K. Agaram 2023-06-21 22:48:47 -07:00
parent 68adcf8408
commit 4735a138da
4 changed files with 24 additions and 2 deletions

View File

@ -3,9 +3,22 @@ on.mouse_press = function(x,y, mouse_button)
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

View File

@ -3,6 +3,7 @@ on.keychord_press = function(chord, key)
if Global_state.thread and chord == 'C-o' then
Global_state.thread = nil
reset_viewport()
A()
elseif chord == 'C-=' then
-- zoom in
Viewport.zoom = Viewport.zoom+0.1

4
0028-A
View File

@ -3,9 +3,9 @@ A = function(preserve_screen_top_of_cursor_node)
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
-- translate some page in Global_state to Surface
Surface = {}
if Global_state.file_picker then
if Global_state.thread == nil then
lay_out_file_picker()
elseif Global_state.thread then
else
compute_layout(Global_state.thread, 0,0, Surface, preserve_screen_top_of_cursor_node)
end
-- continue the pipeline

8
0132-in_rect Normal file
View File

@ -0,0 +1,8 @@
in_rect = function(rect, x,y)
-- return true if x,y in viewport coordinates lie with rect on the surface
if x < vx(rect.x) then return end
if y < vy(rect.y) then return end
if x > vx(rect.x+rect.w) then return end
if y > vy(rect.y+rect.h) then return end
return true
end