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.
This commit is contained in:
Kartik K. Agaram 2022-05-30 15:34:53 -07:00
parent 714f7d11cd
commit fd5a47f8bf
1 changed files with 10 additions and 3 deletions

View File

@ -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}