about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-12-16 23:49:20 -0800
committerKartik K. Agaram <vc@akkartik.com>2023-12-16 23:49:20 -0800
commitaa4d80f157a46eccaf8d6f85033142e44e958e96 (patch)
treef11ff4efade72bf0ebcf3f2ac91832923a230a31
parent67e3a43b523d1398dbfc5b2f9c4ab129921ee4bb (diff)
parentc29be0ffce7132d607077b3e7dda342fc3c4c461 (diff)
downloadtext.love-aa4d80f157a46eccaf8d6f85033142e44e958e96.tar.gz
Merge lines.love
-rw-r--r--button.lua8
-rw-r--r--reference.md4
-rw-r--r--source_edit.lua2
-rw-r--r--source_text_tests.lua1
-rw-r--r--text_tests.lua1
5 files changed, 6 insertions, 10 deletions
diff --git a/button.lua b/button.lua
index 4dfd036..36923e2 100644
--- a/button.lua
+++ b/button.lua
@@ -9,9 +9,6 @@
 
 -- draw button and queue up event handlers
 function button(State, name, params)
-  if State.button_handlers == nil then
-    State.button_handlers = {}
-  end
   love.graphics.setColor(params.bg.r, params.bg.g, params.bg.b, params.bg.a)
   love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5)
   if params.icon then params.icon(params) end
@@ -19,10 +16,7 @@ function button(State, name, params)
 end
 
 -- process button event handlers
-function mouse_press_consumed_by_any_button_handler(State, x, y, mouse_button)
-  if State.button_handlers == nil then
-    return
-  end
+function mouse_press_consumed_by_any_button(State, x, y, mouse_button)
   local button_pressed = false
   local consume_press = true
   for _,ev in ipairs(State.button_handlers) do
diff --git a/reference.md b/reference.md
index 1f1f724..7758cf1 100644
--- a/reference.md
+++ b/reference.md
@@ -283,7 +283,7 @@ The following facilities help set these things up:
   everything about a button in one place. Create as many buttons as you like
   within a single shared `state`.
 
-* `mouse_press_consumed_by_any_button_handler(state, x,y, mouse_button)`
+* `mouse_press_consumed_by_any_button(state, x,y, mouse_button)`
 
   Call this either directly or indirectly from `App.mousepressed`. It will
   pass on a click to any button registered in `state`. It's also helpful to
@@ -291,7 +291,7 @@ The following facilities help set these things up:
   following boilerplate early in `mousepressed`:
 
     ```
-    if mouse_press_consumed_by_any_button_handler(state, x,y, mouse_button) then
+    if mouse_press_consumed_by_any_button(state, x,y, mouse_button) then
       return
     end
     ```
diff --git a/source_edit.lua b/source_edit.lua
index 40af2e8..0af9949 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -239,7 +239,7 @@ 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
+  if mouse_press_consumed_by_any_button(State, x,y, mouse_button) then
     -- press on a button and it returned 'true' to short-circuit
     return
   end
diff --git a/source_text_tests.lua b/source_text_tests.lua
index 0b45232..0d2eb48 100644
--- a/source_text_tests.lua
+++ b/source_text_tests.lua
@@ -881,6 +881,7 @@ function test_select_text_using_mouse_starting_above_text_wrapping_line()
   Editor_state.screen_top1 = {line=2, pos=3}
   Editor_state.screen_bottom1 = {}
   -- press mouse above first line of text
+  edit.draw(Editor_state)
   edit.run_after_mouse_press(Editor_state, Editor_state.left+8,5, 1)
   -- selection is at screen top
   check(Editor_state.selection1.line ~= nil, 'selection:line-not-nil')
diff --git a/text_tests.lua b/text_tests.lua
index 8c2dc3a..bedd73d 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -855,6 +855,7 @@ function test_select_text_using_mouse_starting_above_text_wrapping_line()
   Editor_state.screen_top1 = {line=2, pos=3}
   Editor_state.screen_bottom1 = {}
   -- press mouse above first line of text
+  edit.draw(Editor_state)
   edit.run_after_mouse_press(Editor_state, Editor_state.left+8,5, 1)
   -- selection is at screen top
   check(Editor_state.selection1.line ~= nil, 'selection:line-not-nil')