Small Fixes

Fixed Scrollbar issue causing too long without yield
Fixed ignoreOffset bug
This commit is contained in:
Robert Jelic
2023-05-03 21:00:20 +02:00
parent 4247277d88
commit 4f0d154b31
5 changed files with 35 additions and 5 deletions

View File

@@ -343,6 +343,9 @@ return function(name, basalt)
if(self.getOffset~=nil)then
xO, yO = self:getOffset()
end
if(obj.element.getIgnoreOffset())then
xO, yO = 0, 0
end
if (obj.element[v[1]](obj.element, btn, x+xO, y+yO, ...)) then
return true
end

View File

@@ -141,7 +141,7 @@ return function(name, basalt)
end,
sendEvent = function(self, event, ...)
return eventSystem:sendEvent(event, self, ...)
return eventSystem:sendEvent(event, self, event, ...)
end,
onClick = function(self, ...)

View File

@@ -10,7 +10,7 @@ return function(name, basalt)
local barType = "vertical"
local symbol = " "
local symbolBG = colors.yellow
local symbolBG = colors.black
local symbolFG = colors.black
local scrollAmount = 3
local index = 1
@@ -23,6 +23,7 @@ return function(name, basalt)
symbolSize = math.max((barType == "vertical" and h or w-(#symbol)) - (scrollAmount-1), 1)
end
end
updateSymbolSize()
local function mouseEvent(self, button, x, y)
local obx, oby = self:getPosition()
@@ -67,7 +68,7 @@ return function(name, basalt)
index = 1
end
local w,h = self:getSize()
index = math.min(index, (barType == "vertical" and h or w) - (symbolSize - 1))
--index = math.min(index, (barType == "vertical" and h or w) - (symbolSize - 1))
updateSymbolSize()
self:updateDraw()
return self
@@ -145,8 +146,9 @@ return function(name, basalt)
return self
end,
scrollbarMoveHandler = function(self)
self:sendEvent("scrollbar_moved", self, self:getIndex())
self:sendEvent("scrollbar_moved", self:getIndex())
end,
customEventHandler = function(self, event, ...)
@@ -170,7 +172,7 @@ return function(name, basalt)
for n = 0, h - 1 do
if (index == n + 1) then
for curIndexOffset = 0, math.min(symbolSize - 1, h) do
self:blit(1, index + curIndexOffset, symbol:rep(math.max(#symbol, w)), tHex[symbolFG]:rep(math.max(#symbol, w)), tHex[symbolBG]:rep(math.max(#symbol, w)))
self:addBlit(1, index + curIndexOffset, symbol:rep(math.max(#symbol, w)), tHex[symbolFG]:rep(math.max(#symbol, w)), tHex[symbolBG]:rep(math.max(#symbol, w)))
end
end
end

View File

@@ -212,6 +212,10 @@ return function(name, basalt)
return self
end,
getIgnoreOffset = function(self)
return ignOffset
end,
isCoordsInObject = function(self, x, y)
if(isVisible)and(self:isEnabled())then
if(x==nil)or(y==nil)then return false end