Fixed slider not working on monitors

Fixed sending wrong mouse button on monitor_touch events
This commit is contained in:
Robert Jelic
2025-04-19 06:25:44 +02:00
parent ec9b3ef579
commit afe00c4002
2 changed files with 5 additions and 3 deletions

View File

@@ -167,10 +167,10 @@ function BaseFrame:monitor_touch(name, x, y)
if _term == nil then return end
if(isPeripheral(_term))then
if self._peripheralName == name then
self:mouse_click(0, x, y)
self:mouse_click(1, x, y)
self.basalt.schedule(function()
sleep(0.1)
self:mouse_up(0, x, y)
self:mouse_up(1, x, y)
end)
end
end

View File

@@ -63,7 +63,8 @@ end
--- @return boolean handled Whether the event was handled
--- @protected
function Slider:mouse_click(button, x, y)
if button == 1 and self:isInBounds(x, y) then
self.basalt.LOGGER.debug("Slider:mouse_click", button, x, y)
if self:isInBounds(x, y) then
local relX, relY = self:getRelativePosition(x, y)
local pos = self.get("horizontal") and relX or relY
local maxSteps = self.get("horizontal") and self.get("width") or self.get("height")
@@ -72,6 +73,7 @@ function Slider:mouse_click(button, x, y)
self:updateRender()
return true
end
return false
end
Slider.mouse_drag = Slider.mouse_click