about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-03 08:11:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-03 08:11:18 -0700
commit73cc12047e7eb8162c1f1a2f19be77bb821be85a (patch)
tree9e48f4e7cb46ae1877b2725d8276ddc5a2f277fb /main.lua
parent9efeae1f82738ecab185dae2d16a5e4c13f91aa0 (diff)
downloadtext.love-73cc12047e7eb8162c1f1a2f19be77bb821be85a.tar.gz
select text using mouse drag
Doesn't yet highlight while dragging.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/main.lua b/main.lua
index 3479cbc..d20fd2c 100644
--- a/main.lua
+++ b/main.lua
@@ -198,16 +198,8 @@ function App.mousepressed(x,y, mouse_button)
   for line_index,line in ipairs(Lines) do
     if line.mode == 'text' then
       if Text.in_line(line, x,y) then
-        if love.keyboard.isDown('lshift') or love.keyboard.isDown('rshift') then
-          if Selection1.line == nil then
-            Selection1 = {line=Cursor1.line, pos=Cursor1.pos}
-          end
-        else
-          if Selection1.line then
-            Selection1 = {}
-          end
-        end
         Text.move_cursor(line_index, line, x, y)
+        Selection1 = {line=Cursor1.line, pos=Cursor1.pos}
       end
     elseif line.mode == 'drawing' then
       if Drawing.in_drawing(line, x, y) then
@@ -219,7 +211,20 @@ end
 
 function App.mousereleased(x,y, button)
   if Search_term then return end
-  Drawing.mouse_released(x,y, button)
+  if Lines.current_drawing then
+    Drawing.mouse_released(x,y, button)
+  else
+    for line_index,line in ipairs(Lines) do
+      if line.mode == 'text' then
+        if Text.in_line(line, x,y) then
+          Text.move_cursor(line_index, line, x, y)
+          if Text.eq1(Cursor1, Selection1) then
+            Selection1 = {}
+          end
+        end
+      end
+    end
+  end
 end
 
 function App.textinput(t)