Docs changes

This commit is contained in:
Robert Jelic
2025-02-24 23:54:07 +01:00
parent a98475a442
commit a3cc685620
21 changed files with 188 additions and 133 deletions

View File

@@ -33,6 +33,7 @@ TextBox.defineEvent(TextBox, "mouse_scroll")
--- Creates a new TextBox instance
--- @shortDescription Creates a new TextBox instance
--- @return TextBox self The newly created TextBox instance
--- @private
function TextBox.new()
local self = setmetatable({}, TextBox):__init()
self.set("width", 20)
@@ -40,11 +41,11 @@ function TextBox.new()
return self
end
--- Initializes the TextBox instance
--- @shortDescription Initializes the TextBox instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return TextBox self The initialized instance
--- @protected
function TextBox:init(props, basalt)
VisualElement.init(self, props, basalt)
self.set("type", "TextBox")
@@ -55,6 +56,7 @@ end
--- @shortDescription Adds a new syntax highlighting pattern
--- @param pattern string The regex pattern to match
--- @param color colors The color to apply
--- @return TextBox self The TextBox instance
function TextBox:addSyntaxPattern(pattern, color)
table.insert(self.get("syntaxPatterns"), {pattern = pattern, color = color})
return self
@@ -134,20 +136,20 @@ function TextBox:updateViewport()
return self
end
--- Handles character input
--- @shortDescription Handles character input
--- @param char string The character that was typed
--- @return boolean handled Whether the event was handled
--- @protected
function TextBox:char(char)
if not self.get("editable") or not self.get("focused") then return false end
insertChar(self, char)
return true
end
--- Handles key events
--- @shortDescription Handles key events
--- @param key number The key that was pressed
--- @return boolean handled Whether the event was handled
--- @protected
function TextBox:key(key)
if not self.get("editable") or not self.get("focused") then return false end
local lines = self.get("lines")
@@ -184,12 +186,12 @@ function TextBox:key(key)
return true
end
--- Handles mouse scroll events
--- @shortDescription Handles mouse scroll events
--- @param direction number The scroll direction
--- @param x number The x position of the scroll
--- @param y number The y position of the scroll
--- @return boolean handled Whether the event was handled
--- @protected
function TextBox:mouse_scroll(direction, x, y)
if self:isInBounds(x, y) then
local scrollY = self.get("scrollY")
@@ -207,12 +209,12 @@ function TextBox:mouse_scroll(direction, x, y)
return false
end
--- Handles mouse click events
--- @shortDescription Handles mouse click events
--- @param button number The button that was clicked
--- @param x number The x position of the click
--- @param y number The y position of the click
--- @return boolean handled Whether the event was handled
--- @protected
function TextBox:mouse_click(button, x, y)
if VisualElement.mouse_click(self, button, x, y) then
local relX, relY = self:getRelativePosition(x, y)
@@ -274,8 +276,8 @@ local function applySyntaxHighlighting(self, line)
return text, colors
end
--- Renders the TextBox
--- @shortDescription Renders the TextBox with syntax highlighting
--- @protected
function TextBox:render()
VisualElement.render(self)