mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
fix EditBox Get/SetCursorPosition
workaround for Numeric and with character limits
This commit is contained in:
@@ -430,6 +430,18 @@ function EditBoxGetCursorPosition(self)
|
||||
local otc = removeScript(self, "OnTextChanged")
|
||||
local ots = removeScript(self, "OnTextSet")
|
||||
|
||||
local charsChanged, numeric
|
||||
|
||||
local maxChars = self:GetMaxLetters()
|
||||
if maxChars == self:GetNumLetters() then
|
||||
self:SetMaxLetters(maxChars + 1)
|
||||
charsChanged = true
|
||||
end
|
||||
if self:IsNumeric() then
|
||||
self:SetNumeric(false)
|
||||
numeric = true
|
||||
end
|
||||
|
||||
self:Insert(nbsp)
|
||||
|
||||
local pos = find(self:GetText(), nbsp)
|
||||
@@ -441,6 +453,13 @@ function EditBoxGetCursorPosition(self)
|
||||
self:Insert("")
|
||||
end
|
||||
|
||||
if charsChanged then
|
||||
self:SetMaxLetters(maxChars)
|
||||
end
|
||||
if numeric then
|
||||
self:SetNumeric(true)
|
||||
end
|
||||
|
||||
if occ then self:SetScript("OnCursorChanged", occ) end
|
||||
if otc then self:SetScript("OnTextChanged", otc) end
|
||||
if ots then self:SetScript("OnTextSet", ots) end
|
||||
@@ -467,12 +486,31 @@ function EditBoxSetCursorPosition(self, pos)
|
||||
end
|
||||
|
||||
if pos == 0 then
|
||||
local charsChanged, numeric
|
||||
|
||||
local maxChars = self:GetMaxLetters()
|
||||
if maxChars == self:GetNumLetters() then
|
||||
self:SetMaxLetters(maxChars + 1)
|
||||
charsChanged = true
|
||||
end
|
||||
if self:IsNumeric() then
|
||||
self:SetNumeric(false)
|
||||
numeric = true
|
||||
end
|
||||
|
||||
text = sub(text, 0, 1)
|
||||
self:HighlightText(0, 1)
|
||||
self:Insert(nbsp)
|
||||
self:Insert(text)
|
||||
self:HighlightText(0, 1)
|
||||
self:Insert("")
|
||||
|
||||
if charsChanged then
|
||||
self:SetMaxLetters(maxChars)
|
||||
end
|
||||
if numeric then
|
||||
self:SetNumeric(true)
|
||||
end
|
||||
else
|
||||
text = sub(text, pos, pos)
|
||||
self:HighlightText(pos - 1, pos)
|
||||
|
||||
Reference in New Issue
Block a user