From 89b30a62efda3aa662826801e3e8d70779996569 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 18 Sep 2022 01:26:20 -0700 Subject: [PATCH] support mouse clicks in file navigator --- app.lua | 4 ++++ commands.lua | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app.lua b/app.lua index 994f0c7..62ecd38 100644 --- a/app.lua +++ b/app.lua @@ -194,6 +194,10 @@ function App.color(color) love.graphics.setColor(color.r, color.g, color.b, color.a) end +function colortable(app_color) + return {app_color.r, app_color.g, app_color.b, app_color.a} +end + App.time = 1 function App.getTime() return App.time diff --git a/commands.lua b/commands.lua index bf662ec..71d74f0 100644 --- a/commands.lua +++ b/commands.lua @@ -93,10 +93,17 @@ function add_file_to_menu(x,y, s, cursor_highlight) y = y + Editor_state.line_height x = 5 end + local color = Menu_background_color if cursor_highlight then - App.color(Menu_highlight_color) - love.graphics.rectangle('fill', x-5,y-2, width+5*2,Editor_state.line_height+2*2) + color = Menu_highlight_color end + button(Editor_state, 'menu', {x=x-5, y=y-2, w=width+5*2, h=Editor_state.line_height+2*2, color=colortable(color), + onpress1 = function() + local candidate = guess_source(s..'.lua') + source.switch_to_file(candidate) + Show_file_navigator = false + end + }) App.color(Menu_command_color) App.screen.draw(s_text, x,y) x = x + width + 30