From b5b5234613edbd604885804e4606df99b4bb5f18 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 19 May 2024 22:27:19 -0700 Subject: [PATCH 1/4] only show tooltips when window in focus --- 0012-on.draw | 4 +++- 0177-Window_in_focus | 1 + 0178-on.focus | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 0177-Window_in_focus create mode 100644 0178-on.focus diff --git a/0012-on.draw b/0012-on.draw index 44b685f..6389088 100644 --- a/0012-on.draw +++ b/0012-on.draw @@ -25,5 +25,7 @@ on.draw = function() end draw_menu() draw_next_frames_of_animations() - draw_button_tooltips(Global_state) + if Window_in_focus then + draw_button_tooltips(Global_state) + end end \ No newline at end of file diff --git a/0177-Window_in_focus b/0177-Window_in_focus new file mode 100644 index 0000000..353ec2a --- /dev/null +++ b/0177-Window_in_focus @@ -0,0 +1 @@ +Window_focus = true \ No newline at end of file diff --git a/0178-on.focus b/0178-on.focus new file mode 100644 index 0000000..a7acca6 --- /dev/null +++ b/0178-on.focus @@ -0,0 +1,3 @@ +on.focus = function(in_focus) + Window_in_focus = in_focus +end \ No newline at end of file From b6102d04897a795818cd43ff2d48e20417a927e5 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 19 May 2024 22:40:27 -0700 Subject: [PATCH 2/4] mousemoved handler --- main.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.lua b/main.lua index b40ddf2..2cb7192 100644 --- a/main.lua +++ b/main.lua @@ -319,6 +319,17 @@ function App.mousereleased(x,y, mouse_button) end end +function App.mousemoved(x,y, dx,dy, is_touch) + if current_app_is_warning() then return end + if Current_app == 'run' then + if run.mouse_move then run.mouse_move(dx,dy) end + elseif Current_app == 'source' then + if source.mouse_move then source.mouse_move(dx,dy) end + else + assert(false, 'unknown app "'..Current_app..'"') + end +end + function App.wheelmoved(dx,dy) if current_app_is_warning() then return end if Current_app == 'run' then From 8219db2bcd31bee0f5cf5c4a92c3f6cd6a684e6d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 19 May 2024 22:41:52 -0700 Subject: [PATCH 3/4] mousefocus handler --- main.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.lua b/main.lua index 2cb7192..232308e 100644 --- a/main.lua +++ b/main.lua @@ -341,6 +341,17 @@ function App.wheelmoved(dx,dy) end end +function App.mousefocus(in_focus) + if current_app_is_warning() then return end + if Current_app == 'run' then + if run.mouse_focus then run.mouse_focus(in_focus) end + elseif Current_app == 'source' then + if source.mouse_focus then source.mouse_focus(in_focus) end + else + assert(false, 'unknown app "'..Current_app..'"') + end +end + function love.quit() if Disable_all_quit_handlers then return end if current_app_is_warning() then return end From 3e0cb2ed10c35961ea357afc674de204e9c9c83c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 19 May 2024 23:13:52 -0700 Subject: [PATCH 4/4] document recent handlers --- reference.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reference.md b/reference.md index 8256e1d..1aadc41 100644 --- a/reference.md +++ b/reference.md @@ -73,12 +73,19 @@ automatically called for you as appropriate. button. Provides the same arguments as `App.mousepressed()` above. (Based on [LÖVE](https://love2d.org/wiki/love.mousereleased).) +* `App.mousemoved(x,y, dx,dy, is_touch)` -- called any time the mouse moves. + (Based on [LÖVE](https://love2d.org/wiki/love.mousemoved).) + * `App.wheelmoved(dx,dy)` -- called when you use the scroll wheel on a mouse that has it. Provides in `dx` and `dy` an indication of how fast the wheel is being scrolled. Positive values for `dx` indicate movement to the right. Positive values for `dy` indicate upward movement. (Based on [LÖVE](https://love2d.org/wiki/love.wheelmoved).) +* `App.mousefocus(in_focus)` -- called when the mouse pointer moves on or off + the app window. + (Based on [LÖVE](https://love2d.org/wiki/love.mousefocus).) + * `App.keychord_press(chord, key)` -- called when you press a key-combination. Provides in `key` a string name for the key most recently pressed ([valid values](https://love2d.org/wiki/KeyConstant)). Provides in `chord` a