This is an example provided during a Discord dicussion. I thought it could be better to post it here if anyone is interested.
local ui = require "ui"
local win = ui.Window("Window mouse dragging")
local panel = ui.Panel(win)
panel.bgcolor = 0x2020D0
local isMoving = false
local dx, dy
function panel:onMouseDown(b,x,y)
if b == "left" then
isMoving = true
dx = x
dy = y
end
end
function win:onMouseUp()
isMoving = false
end
panel.onMouseUp = win.onMouseUp
function panel:onHover(x,y)
if isMoving then
win.x = win.x - (dx - x)
win.y = win.y - (dy - y)
end
end
ui.run(win):wait()