Updates to input object

main
jeffi 1 year ago
parent cdfd19362f
commit 4378d3366c
  1. 7
      DiesalGUI-2.0/Objects/Input.lua
  2. 10
      DiesalGUI-2.0/Objects/ObjectBase.lua

@ -48,22 +48,28 @@ local Stylesheet = {
-- ~~| Spinner Methods |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---@class Diesal.GUI.Input.Methods
local methods = {
---@param self Diesal.GUI.Object.Input
["OnAcquire"] = function(self)
self:SetStylesheet(Stylesheet)
self:ApplySettings()
self:Show()
end,
---@param self Diesal.GUI.Object.Input
["OnRelease"] = function(self) end,
---@param self Diesal.GUI.Object.Input
["ApplySettings"] = function(self)
self:SetWidth(self.settings.width)
self:SetHeight(self.settings.height)
end,
---@param self Diesal.GUI.Object.Input
["GetText"] = function(self)
return self.editBox:GetText()
end,
---@param self Diesal.GUI.Object.Input
["SetText"] = function(self, txt)
self.editBox:SetText(txt)
end,
---@param self Diesal.GUI.Object.Input
["SetTextColor"] = function(self, color, alpha)
alpha = alpha or 1
color = { DiesalTools.GetColor(color) }
@ -76,6 +82,7 @@ local methods = {
-- | Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local function Constructor()
---@class Diesal.GUI.Object.Input : Diesal.GUI.ObjectBase, Diesal.GUI.Input.Methods
---@field editBox EditBox
local self = DiesalGUI:Create(Type, true)
local frame = CreateFrame("Frame", nil, UIParent)
self.frame = frame

@ -48,6 +48,7 @@ local ObjectBase = {
---@generic T : Diesal.GUI.ObjectBase
---@param self T | Diesal.GUI.ObjectBase
---@param width number
SetWidth = function(self, width)
self.settings.width = width
self.frame:SetWidth(width)
@ -475,18 +476,15 @@ local Constructor = function(objectType)
setmetatable(object, {
---@param self Diesal.GUI.ObjectBase
---@param k string
__index = function(self, k)
local response = rawget(object, k)
if response ~= nil then
return response
end
-- Look for replaced methods.
response = object.methods[k]
local response = self.methods[k]
if response ~= nil then
return response
end
return rawget(object, k)
return rawget(self, k)
end,
})
return object

Loading…
Cancel
Save