From 3f51f24f9161ecc3417b52acc6244822e9f0a44b Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 30 Apr 2023 17:12:43 -0700 Subject: [PATCH] fix errors when dragging a scrollbar and the mouse leaves the window --- library/lua/gui/widgets.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index c7cde698c..7eeb00f1f 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -836,7 +836,9 @@ function Scrollbar:update(top_elem, elems_per_page, num_elems) end local function scrollbar_do_drag(scrollbar) - local _,y = scrollbar.frame_body:localXY(dfhack.screen.getMousePos()) + local x,y = dfhack.screen.getMousePos() + if not y then return end + x,y = scrollbar.frame_body:localXY(x, y) local cur_pos = y - scrollbar.is_dragging local max_top = scrollbar.num_elems - scrollbar.elems_per_page + 1 local max_pos = scrollbar_get_max_pos_and_height(scrollbar)