diff options
-rw-r--r-- | button.lua | 8 | ||||
-rw-r--r-- | edit.lua | 2 | ||||
-rw-r--r-- | reference.md | 4 | ||||
-rw-r--r-- | source_edit.lua | 2 | ||||
-rw-r--r-- | source_text_tests.lua | 1 | ||||
-rw-r--r-- | text_tests.lua | 1 |
6 files changed, 7 insertions, 11 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/edit.lua b/edit.lua index cfc1478..7b913fc 100644 --- a/edit.lua +++ b/edit.lua @@ -235,7 +235,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/reference.md b/reference.md index 916c8f4..51c547b 100644 --- a/reference.md +++ b/reference.md @@ -294,7 +294,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 @@ -302,7 +302,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 41fe2df..430733a 100644 --- a/text_tests.lua +++ b/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') |