WoWInterface SVN PhanxConfigWidgets

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/PhanxConfig-EditBox
    from Rev 185 to Rev 188
    Reverse comparison

Rev 185 → Rev 188

PhanxConfig-EditBox.lua
2,12 → 2,11
PhanxConfig-EditBox
Simple text input widget generator.
Requires LibStub.
https://github.com/phanx/PhanxConfigWidgets
Copyright (c) 2009-2014 Phanx. All rights reserved.
See the accompanying README and LICENSE files for more information.
https://github.com/phanx/PhanxConfigWidgets
----------------------------------------------------------------------]]
 
local MINOR_VERSION = tonumber(string.match("$Revision$", "%d+"))
local MINOR_VERSION = 176
 
local lib, oldminor = LibStub:NewLibrary("PhanxConfig-EditBox", MINOR_VERSION)
if not lib then return end
39,7 → 38,7
GameTooltip:SetText(container.tooltipText, nil, nil, nil, nil, true)
end
end
function scripts:OnLeave()
local function OnLeave()
GameTooltip:Hide()
end
 
54,16 → 53,16
self.currText, self.origText = nil, nil
end
 
function scripts:OnTextChanged(userInput)
function scripts:OnTextChanged()
if not self:HasFocus() then return end
 
local text = self:GetText()
if text:len() == 0 then text = nil end -- experimental
 
local parent = self:GetParent()
local callback = parent.OnTextChanged
local callback = parent.CallbackOnTextChanged or parent.OnTextChanged
if callback and text ~= self.currText then
callback(parent, text, userInput)
callback(parent, text)
self.currText = text
end
end
74,7 → 73,7
self:ClearFocus()
 
local parent = self:GetParent()
local callback = parent.OnValueChanged
local callback = parent.Callback or parent.OnValueChanged
if callback then
callback(parent, text)
end
85,59 → 84,17
end
 
function scripts:OnReceiveDrag()
local type, arg1, arg2, arg3, arg4 = GetCursorInfo()
local type, id, info = GetCursorInfo()
if type == "item" then
-- itemID, itemLink
if self:IsNumeric() then
self:SetNumber(arg1)
else
local name = GetItemInfo(arg1)
self:SetText(name)
end
elseif type == "macro" then
-- index
if self:IsNumeric() then
self:SetNumber(arg1)
else
local name = GetMacroInfo(arg1)
self:SetText(name)
end
elseif type == "merchant" then
-- index
if self:IsNumeric() then
local link = GetMerchantItemLink(arg1)
local id = strmatch(link, "|Hitem:(%d+)")
if id then
self:SetNumber(id)
else
self:SetText("")
end
else
local name = GetMerchantItemInfo(arg1)
self:SetText(name)
end
elseif type == "money" then
-- amount in copper
if self:IsNumeric() then
self:SetNumber(arg1)
else
local mode = ENABLE_COLORBLIND_MODE
ENABLE_COLORBLIND_MODE = "1"
local text = GetMoneyString(arg1)
ENABLE_COLORBLIND_MODE = mode
self:SetText(text)
end
self:SetText(info)
scripts.OnEnterPressed(self)
ClearCursor()
elseif type == "spell" then
-- index, bookType, spellID
if self:IsNumeric() then
self:SetNumber(arg3)
else
local name = GetSpellInfo(arg3)
self:SetText(name)
end
local name = GetSpellInfo(id, info)
self:SetText(name)
scripts.OnEnterPressed(self)
ClearCursor()
end
scripts.OnEnterPressed(self)
ClearCursor()
end
 
------------------------------------------------------------------------
190,7 → 147,6
editbox:SetPoint("RIGHT", -5, 0)
editbox:SetHeight(19)
editbox:EnableMouse(true)
editbox:SetAltArrowKeyMode(false)
editbox:SetAutoFocus(false)
editbox:SetFontObject(ChatFontNormal)
editbox:SetMaxLetters(maxLetters or 256)
199,22 → 155,20
frame.editbox = editbox
 
editbox.bgLeft = editbox:CreateTexture(nil, "BACKGROUND")
editbox.bgLeft:SetPoint("TOPLEFT", 0, 0)
editbox.bgLeft:SetPoint("BOTTOMLEFT", 0, 0)
editbox.bgLeft:SetPoint("LEFT", 0, 0)
editbox.bgLeft:SetSize(8, 20)
editbox.bgLeft:SetTexture([[Interface\Common\Common-Input-Border]])
editbox.bgLeft:SetTexCoord(0, 0.0625, 0, 0.625)
 
editbox.bgRight = editbox:CreateTexture(nil, "BACKGROUND")
editbox.bgRight:SetPoint("TOPRIGHT", 0, 0)
editbox.bgRight:SetPoint("BOTTOMRIGHT", 0, 0)
editbox.bgRight:SetPoint("RIGHT", 0, 0)
editbox.bgRight:SetSize(8, 20)
editbox.bgRight:SetTexture([[Interface\Common\Common-Input-Border]])
editbox.bgRight:SetTexCoord(0.9375, 1, 0, 0.625)
 
editbox.bgMiddle = editbox:CreateTexture(nil, "BACKGROUND")
editbox.bgMiddle:SetPoint("TOPLEFT", editbox.bgLeft, "TOPRIGHT")
editbox.bgMiddle:SetPoint("BOTTOMRIGHT", editbox.bgRight, "BOTTOMLEFT")
editbox.bgMiddle:SetPoint("LEFT", editbox.bgLeft, "RIGHT")
editbox.bgMiddle:SetPoint("RIGHT", editbox.bgRight, "LEFT")
editbox.bgMiddle:SetSize(10, 20)
editbox.bgMiddle:SetTexture([[Interface\Common\Common-Input-Border]])
editbox.bgMiddle:SetTexCoord(0.0625, 0.9375, 0, 0.625)