partition handlers between screen regions

This fixes one bug I know of: dragging the mouse atop the settings menu
was selecting text in the editor underneath.
This commit is contained in:
Kartik K. Agaram 2023-12-01 20:55:39 -08:00
parent e0a0c4f33b
commit 7ca2006145
4 changed files with 27 additions and 8 deletions

View File

@ -1,15 +1,18 @@
on.update = function(dt)
refresh_debug_animations()
-- == menu area
if Active_button and Active_button.expire <= Current_time then
Active_button = nil
end
-- == settings area
if Selected_slider then
update_any_sliders(App.mouse_x(), App.mouse_y())
end
-- main area
if Current_pane.editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.editor_state, App.mouse_y())
elseif Current_pane.output_editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.output_editor_state, App.mouse_y())
end
if car.update then call_protected(car.update, dt) end
end
end

View File

@ -1,20 +1,25 @@
on.mouse_press = function(x,y, mouse_button)
-- == menu area
-- some hysteresis right after a button has been pressed
if Active_button then return end
if mouse_press_consumed_by_any_button_handler(Global_state, x,y, mouse_button) then
Button_pressed = true
return
end
Show_overflow = false
if mouse_on_any_slider(x,y, mouse_button) then
return
end
if not on_area(Settings_menu_area, x,y) then
if Show_settings then
-- On mobile devices, we can't depend on on.save_settings() triggering on quit
-- == settings area
if Show_settings then
if on_area(Settings_menu_area, x,y) then
mouse_on_any_slider(x,y, mouse_button)
else
Show_settings = false
-- On mobile devices, we can't depend on on.save_settings() triggering on quit.
-- So save settings every time we close the settings menu.
love.filesystem.write('config', json.encode(settings()))
end
Show_settings = false
return
end
-- == main area
if Show_code then
if on_editor_scrollbar(Current_pane.editor_state, x,y) then
Current_pane.editor_state.scrollbar_drag = true

View File

@ -1,5 +1,15 @@
on.mouse_release = function(x,y, mouse_button)
-- == menu area
Selected_slider = nil
if Button_pressed then
Button_pressed = nil
return
end
-- == settings area
if on_area(Settings_menu_area, x,y) then
return
end
-- == main area
if Show_code then
if Current_pane.editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.editor_state, y)

1
0150-Button_pressed Normal file
View File

@ -0,0 +1 @@
Button_pressed = nil