about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-12-01 22:07:24 -0800
committerKartik K. Agaram <vc@akkartik.com>2023-12-01 22:07:24 -0800
commit8399c4270745be269e335b07106f1ba95c93334d (patch)
treec0f8da72f7aa6c012f00b523d868bc0b07680265
parent8a588880b7e7e808dc73e9e6b7e5eb7a42c1e2cb (diff)
downloadtext.love-8399c4270745be269e335b07106f1ba95c93334d.tar.gz
mouse button state in source editor
-rw-r--r--source_edit.lua2
-rw-r--r--source_select.lua2
2 files changed, 3 insertions, 1 deletions
diff --git a/source_edit.lua b/source_edit.lua
index 6259ebe..9d37466 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -237,6 +237,7 @@ end
 
 function edit.mouse_press(State, x,y, mouse_button)
   if State.search_term then return end
+  State.mouse_down = mouse_button
 --?   print_and_log(('edit.mouse_press: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
   if mouse_press_consumed_by_any_button_handler(State, x,y, mouse_button) then
     -- press on a button and it returned 'true' to short-circuit
@@ -301,6 +302,7 @@ end
 function edit.mouse_release(State, x,y, mouse_button)
   if State.search_term then return end
 --?   print_and_log(('edit.mouse_release: cursor at %d,%d'):format(State.cursor1.line, State.cursor1.pos))
+  State.mouse_down = nil
   if State.lines.current_drawing then
     Drawing.mouse_release(State, x,y, mouse_button)
     schedule_save(State)
diff --git a/source_select.lua b/source_select.lua
index 9ede1da..5434988 100644
--- a/source_select.lua
+++ b/source_select.lua
@@ -11,7 +11,7 @@ function Text.clip_selection(State, line_index, apos, bpos)
   -- min,max = sorted(State.selection1,State.cursor1)
   local minl,minp = State.selection1.line,State.selection1.pos
   local maxl,maxp
-  if App.mouse_down(1) then
+  if State.mouse_down then
     maxl,maxp = Text.mouse_pos(State)
   else
     maxl,maxp = State.cursor1.line,State.cursor1.pos