about summary refs log tree commit diff stats
path: root/commands.lua
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 /commands.lua
parentbc464fe6f1fc99af269c20e87e7be38ec26de2b3 (diff)
downloadlines.love-89b30a62efda3aa662826801e3e8d70779996569.tar.gz
support mouse clicks in file navigator
Diffstat (limited to 'commands.lua')
-rw-r--r--commands.lua11
1 files changed, 9 insertions, 2 deletions
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