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

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

Loading…
Cancel
Save