fix errors when dragging a scrollbar and the mouse leaves the window

develop
Myk Taylor 2023-04-30 17:12:43 -07:00
parent 923f84b2f2
commit 3f51f24f91
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 3 additions and 1 deletions

@ -836,7 +836,9 @@ function Scrollbar:update(top_elem, elems_per_page, num_elems)
end end
local function scrollbar_do_drag(scrollbar) 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 cur_pos = y - scrollbar.is_dragging
local max_top = scrollbar.num_elems - scrollbar.elems_per_page + 1 local max_top = scrollbar.num_elems - scrollbar.elems_per_page + 1
local max_pos = scrollbar_get_max_pos_and_height(scrollbar) local max_pos = scrollbar_get_max_pos_and_height(scrollbar)