main
jeffi 11 months ago
parent 8c2f43b11e
commit 892f29cd2b
  1. 15
      DiesalGUI-2.0/Objects/Spinner.lua

@ -97,6 +97,7 @@ local wireFrame = {
},
}
-- | Internal Methods |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---@param self Diesal.GUI.Object.Spinner
local function processNumber(self, number)
local settings = self.settings
local number, oldNumber = tonumber(number), self:GetNumber()
@ -241,8 +242,10 @@ local methods = {
---@field bar boolean
---@field min number
---@field max number
---@field step number
---@field prefix? string
---@field shiftStep number
---@field step number
---@field suffix? string
---@class Diesal.GUI.Object.Spinner.Settings: Diesal.GUI.Object.Spinner.Settings.Defaults
---@field number number
@ -251,6 +254,11 @@ local methods = {
local function Constructor()
---@class Diesal.GUI.Object.Spinner : Diesal.GUI.ObjectBase, Diesal.GUI.Spinner.Methods
---@field settings Diesal.GUI.Object.Spinner.Settings
---@field bar Frame
---@field value number
---@field buttonUp Button
---@field buttonDown Button
---@field editBox EditBox
local self = DiesalGUI:Create(Type, true)
local frame = CreateFrame("Frame", nil, UIParent)
self.frame = frame
@ -276,14 +284,15 @@ local function Constructor()
self:UpdateBar()
end)
local editBox = self:CreateRegion("EditBox", "editBox", frame) --[[ @asDiesal.GUI.Region.EditBoxx ]]
local editBox = self:CreateRegion("EditBox", "editBox", frame) --[[ @as Diesal.GUI.Region.EditBox ]]
editBox:SetPoint("TOP")
editBox:SetPoint("BOTTOM")
editBox:SetAutoFocus(false)
editBox:SetJustifyH("CENTER")
editBox:SetJustifyV("CENTER")
editBox:SetTextInsets(0, 0, 0, 0)
editBox:SetText(self.defaults.min)
editBox:SetNumber(self.defaults.min)
---@param this EditBox
editBox:SetScript("OnEnterPressed", function(this, ...)
local number = this:GetNumber() or self.settings.number -- if entered text or nothing revert to old value
local newNumber = processNumber(self, number)

Loading…
Cancel
Save