removed scrollbar from tables
added enabled property
This commit is contained in:
@@ -31,6 +31,9 @@ BaseElement.defineProperty(BaseElement, "name", {default = "", type = "string"})
|
||||
--- @property eventCallbacks table BaseElement The event callbacks for the element
|
||||
BaseElement.defineProperty(BaseElement, "eventCallbacks", {default = {}, type = "table"})
|
||||
|
||||
--- @property enabled boolean BaseElement Whether the element is enabled or not
|
||||
BaseElement.defineProperty(BaseElement, "enabled", {default = true, type = "boolean" })
|
||||
|
||||
--- Registers a new event listener for the element (on class level)
|
||||
--- @shortDescription Registers a new event listener for the element (on class level)
|
||||
--- @param class table The class to register
|
||||
@@ -215,6 +218,9 @@ end
|
||||
--- @return boolean? handled Whether the event was handled
|
||||
--- @protected
|
||||
function BaseElement:dispatchEvent(event, ...)
|
||||
if self.get("enabled") == false then
|
||||
return false
|
||||
end
|
||||
if self[event] then
|
||||
return self[event](self, ...)
|
||||
end
|
||||
|
||||
@@ -216,7 +216,7 @@ function Table:render()
|
||||
local finalText = string.sub(paddedText, 1, col.width)
|
||||
local finalForeground = string.rep(tHex[self.get("foreground")], #finalText)
|
||||
local finalBackground = string.rep(tHex[bg], #finalText)
|
||||
|
||||
|
||||
self:blit(currentX, y, finalText, finalForeground, finalBackground)
|
||||
currentX = currentX + col.width
|
||||
end
|
||||
@@ -226,27 +226,6 @@ function Table:render()
|
||||
string.rep(tHex[self.get("background")], self.get("width")))
|
||||
end
|
||||
end
|
||||
|
||||
if #data > height - 2 then
|
||||
local scrollbarHeight = height - 2
|
||||
local thumbSize = math.max(1, math.floor(scrollbarHeight * (height - 2) / #data))
|
||||
|
||||
local maxScroll = #data - (height - 2) + 1
|
||||
local scrollPercent = scrollOffset / maxScroll
|
||||
local thumbPos = 2 + math.floor(scrollPercent * (scrollbarHeight - thumbSize))
|
||||
|
||||
if scrollOffset >= maxScroll then
|
||||
thumbPos = height - thumbSize
|
||||
end
|
||||
|
||||
for y = 2, height do
|
||||
self:blit(self.get("width"), y, "\127", tHex[colors.gray], tHex[colors.gray])
|
||||
end
|
||||
|
||||
for y = thumbPos, math.min(height, thumbPos + thumbSize - 1) do
|
||||
self:blit(self.get("width"), y, "\127", tHex[colors.white], tHex[colors.white])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Table
|
||||
@@ -99,7 +99,7 @@ VisualElement.registerEventCallback(VisualElement, "ClickUp", "mouse_up", "mouse
|
||||
VisualElement.registerEventCallback(VisualElement, "Drag", "mouse_drag", "mouse_click", "mouse_up")
|
||||
VisualElement.registerEventCallback(VisualElement, "Scroll", "mouse_scroll")
|
||||
VisualElement.registerEventCallback(VisualElement, "Enter", "mouse_enter", "mouse_move")
|
||||
VisualElement.registerEventCallback(VisualElement, "LeEave", "mouse_leave", "mouse_move")
|
||||
VisualElement.registerEventCallback(VisualElement, "Leave", "mouse_leave", "mouse_move")
|
||||
VisualElement.registerEventCallback(VisualElement, "Focus", "focus", "blur")
|
||||
VisualElement.registerEventCallback(VisualElement, "Blur", "blur", "focus")
|
||||
VisualElement.registerEventCallback(VisualElement, "Key", "key", "key_up")
|
||||
|
||||
Reference in New Issue
Block a user