about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-09-18 01:26:20 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-09-18 01:26:20 -0700
commit89b30a62efda3aa662826801e3e8d70779996569 (patch)
treeb4f340beb7a8e59e1194f57ad37f1cd69b62d1fc
parentbc464fe6f1fc99af269c20e87e7be38ec26de2b3 (diff)
downloadtext.love-89b30a62efda3aa662826801e3e8d70779996569.tar.gz
support mouse clicks in file navigator
-rw-r--r--app.lua4
-rw-r--r--commands.lua11
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