about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-30 15:34:53 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-30 15:34:53 -0700
commitfd5a47f8bf513f4fbb97087a7f2fb90721c12b55 (patch)
tree39fef75ffa76deb2277a04cf4cc0e618a8c9bdfc
parent714f7d11cd381ef371e4cdde002e548f4189ee7f (diff)
downloadlines.love-fd5a47f8bf513f4fbb97087a7f2fb90721c12b55.tar.gz
more robust transitions to temporary modes
I seem to often accidentally press C-n twice to go into name mode. Now
doing so overrides the previous temporary mode (name/move/delete point)
without clobbering the real shape-drawing mode.
-rw-r--r--drawing.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/drawing.lua b/drawing.lua
index 417b5a0..822b3ab 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -479,7 +479,9 @@ function Drawing.keychord_pressed(chord)
   elseif chord == 'C-v' and not love.mouse.isDown('1') then
     local drawing,_,p = Drawing.select_point_at_mouse()
     if drawing then
-      Previous_drawing_mode = Current_drawing_mode
+      if Previous_drawing_mode == nil then
+        Previous_drawing_mode = Current_drawing_mode
+      end
       Current_drawing_mode = 'move'
       drawing.pending = {mode=Current_drawing_mode, target_point=p}
       Lines.current = drawing
@@ -487,7 +489,9 @@ function Drawing.keychord_pressed(chord)
   elseif love.mouse.isDown('1') and chord == 'v' then
     local drawing,_,p = Drawing.select_point_at_mouse()
     if drawing then
-      Previous_drawing_mode = Current_drawing_mode
+      if Previous_drawing_mode == nil then
+        Previous_drawing_mode = Current_drawing_mode
+      end
       Current_drawing_mode = 'move'
       drawing.pending = {mode=Current_drawing_mode, target_point=p}
       Lines.current = drawing
@@ -495,7 +499,10 @@ function Drawing.keychord_pressed(chord)
   elseif chord == 'C-n' and not love.mouse.isDown('1') then
     local drawing,point_index,p = Drawing.select_point_at_mouse()
     if drawing then
-      Previous_drawing_mode = Current_drawing_mode
+      if Previous_drawing_mode == nil then
+        -- don't clobber
+        Previous_drawing_mode = Current_drawing_mode
+      end
       Current_drawing_mode = 'name'
       p.name = ''
       drawing.pending = {mode=Current_drawing_mode, target_point=point_index}