2023-11-15 14:06:56 +00:00
|
|
|
on.mouse_press = function(x,y, mouse_button)
|
2023-12-02 04:55:39 +00:00
|
|
|
-- == menu area
|
2023-12-02 04:07:20 +00:00
|
|
|
-- some hysteresis right after a button has been pressed
|
|
|
|
if Active_button then return end
|
2023-12-17 08:53:12 +00:00
|
|
|
if mouse_press_consumed_by_any_button(Global_state, x,y, mouse_button) then
|
2023-12-02 04:55:39 +00:00
|
|
|
Button_pressed = true
|
2023-11-15 15:04:34 +00:00
|
|
|
return
|
|
|
|
end
|
2023-12-02 04:55:39 +00:00
|
|
|
-- == settings area
|
2023-12-17 07:27:52 +00:00
|
|
|
if mouse_press_consumed_by_any_slider(Global_state, x,y) then
|
|
|
|
return
|
|
|
|
end
|
2023-12-05 06:09:47 +00:00
|
|
|
if Show_menu == 'settings' then
|
2023-12-02 04:55:39 +00:00
|
|
|
if on_area(Settings_menu_area, x,y) then
|
2023-12-17 07:27:52 +00:00
|
|
|
-- nothing atm in settings menu that isn't a button or slider
|
2023-12-02 04:55:39 +00:00
|
|
|
else
|
2023-12-05 06:09:47 +00:00
|
|
|
Show_menu = nil
|
2023-12-02 04:55:39 +00:00
|
|
|
-- On mobile devices, we can't depend on on.save_settings() triggering on quit.
|
|
|
|
-- So save settings every time we close the settings menu.
|
2023-12-02 03:55:51 +00:00
|
|
|
love.filesystem.write('config', json.encode(settings()))
|
|
|
|
end
|
2023-12-02 04:55:39 +00:00
|
|
|
return
|
2023-11-21 10:19:56 +00:00
|
|
|
end
|
2023-12-02 04:55:39 +00:00
|
|
|
-- == main area
|
2023-12-05 06:09:47 +00:00
|
|
|
Show_menu = nil
|
2023-11-22 03:17:49 +00:00
|
|
|
if Show_code then
|
|
|
|
if on_editor_scrollbar(Current_pane.editor_state, x,y) then
|
|
|
|
Current_pane.editor_state.scrollbar_drag = true
|
2023-12-03 02:36:11 +00:00
|
|
|
local sbtopy = compute_scrollbar_topy(Current_pane.editor_state)
|
|
|
|
Current_pane.editor_state.scrollbar_offset = y - sbtopy
|
2023-11-22 03:17:49 +00:00
|
|
|
elseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then
|
|
|
|
-- nothing
|
|
|
|
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
|
|
|
|
love.keyboard.setTextInput(true)
|
|
|
|
edit.mouse_press(Current_pane.editor_state, x,y, mouse_button)
|
|
|
|
elseif on_editor_scrollbar(Current_pane.output_editor_state, x,y) then
|
|
|
|
Current_pane.output_editor_state.scrollbar_drag = true
|
2023-12-03 02:36:11 +00:00
|
|
|
local sbtopy = compute_scrollbar_topy(Current_pane.output_editor_state)
|
2023-12-03 06:27:36 +00:00
|
|
|
Current_pane.output_editor_state.scrollbar_offset = y - sbtopy
|
2023-11-22 03:17:49 +00:00
|
|
|
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
|
|
|
|
-- nothing
|
|
|
|
end
|
|
|
|
else
|
|
|
|
-- editors hidden
|
2023-12-07 20:39:20 +00:00
|
|
|
if car.mouse_press then
|
|
|
|
call_protected(car.mouse_press, x,y, mouse_button)
|
|
|
|
end
|
|
|
|
if car.mousepressed then
|
|
|
|
call_protected(car.mousepressed, x,y, mouse_button)
|
|
|
|
end
|
2023-11-18 13:26:28 +00:00
|
|
|
end
|
2023-12-17 08:53:12 +00:00
|
|
|
end
|