Add search box

This commit is contained in:
tekkub 2009-08-15 19:43:17 -06:00
parent 82f4233385
commit cef1ae7700
2 changed files with 54 additions and 1 deletions

View File

@ -202,6 +202,7 @@ local _, _, _, _, _, _, _, _, RECIPE = GetAuctionItemClasses()
local quality_colors = {} local quality_colors = {}
for i=1,7 do quality_colors[i] = select(4, GetItemQualityColor(i)) end for i=1,7 do quality_colors[i] = select(4, GetItemQualityColor(i)) end
local offset = 0 local offset = 0
local searchstring
local function Refresh() local function Refresh()
local n = GetMerchantNumItems() local n = GetMerchantNumItems()
for i,row in pairs(rows) do for i,row in pairs(rows) do
@ -229,6 +230,8 @@ local function Refresh()
row.backdrop:Show() row.backdrop:Show()
end end
row:SetAlpha(searchstring and not name:lower():match(searchstring) and 0.5 or 1)
row.icon:SetTexture(itemTexture) row.icon:SetTexture(itemTexture)
row.ItemName:SetText((numAvailable > -1 and ("["..numAvailable.."] ") or "").. color.. (name or "<Loading item data>").. (itemStackCount > 1 and ("|r x"..itemStackCount) or "")) row.ItemName:SetText((numAvailable > -1 and ("["..numAvailable.."] ") or "").. color.. (name or "<Loading item data>").. (itemStackCount > 1 and ("|r x"..itemStackCount) or ""))
@ -260,6 +263,56 @@ local function Refresh()
end end
local editbox = CreateFrame('EditBox', nil, GVS)
editbox:SetAutoFocus(false)
editbox:SetPoint("TOPLEFT", GVS, "BOTTOMLEFT", 0, -51)
editbox:SetWidth(160)
editbox:SetHeight(32)
editbox:SetFontObject('GameFontHighlightSmall')
local left = editbox:CreateTexture(nil, "BACKGROUND")
left:SetWidth(8) left:SetHeight(20)
left:SetPoint("LEFT", -5, 0)
left:SetTexture("Interface\\Common\\Common-Input-Border")
left:SetTexCoord(0, 0.0625, 0, 0.625)
local right = editbox:CreateTexture(nil, "BACKGROUND")
right:SetWidth(8) right:SetHeight(20)
right:SetPoint("RIGHT", 0, 0)
right:SetTexture("Interface\\Common\\Common-Input-Border")
right:SetTexCoord(0.9375, 1, 0, 0.625)
local center = editbox:CreateTexture(nil, "BACKGROUND")
center:SetHeight(20)
center:SetPoint("RIGHT", right, "LEFT", 0, 0)
center:SetPoint("LEFT", left, "RIGHT", 0, 0)
center:SetTexture("Interface\\Common\\Common-Input-Border")
center:SetTexCoord(0.0625, 0.9375, 0, 0.625)
editbox:SetScript("OnEscapePressed", editbox.ClearFocus)
editbox:SetScript("OnEnterPressed", editbox.ClearFocus)
editbox:SetScript("OnEditFocusGained", function(self)
if not searchstring then
self:SetText("")
self:SetTextColor(1,1,1,1)
end
end)
editbox:SetScript("OnEditFocusLost", function(self)
if self:GetText() == "" then
self:SetText("Search...")
self:SetTextColor(0.75, 0.75, 0.75, 1)
end
end)
editbox:SetScript("OnTextChanged", function(self)
local t = self:GetText()
searchstring = t ~= "" and t ~= "Search..." and t:lower() or nil
Refresh()
end)
editbox:SetScript("OnShow", function(self)
self:SetText("Search...")
self:SetTextColor(0.75, 0.75, 0.75, 1)
end)
local scrollbar = LibStub("tekKonfig-Scroll").new(GVS, 0, SCROLLSTEP) local scrollbar = LibStub("tekKonfig-Scroll").new(GVS, 0, SCROLLSTEP)
local f = scrollbar:GetScript("OnValueChanged") local f = scrollbar:GetScript("OnValueChanged")
scrollbar:SetScript("OnValueChanged", function(self, value, ...) scrollbar:SetScript("OnValueChanged", function(self, value, ...)

View File

@ -9,11 +9,11 @@ h2. Features
* Ctrl- and shift-click behave as default (dress-up and paste link, respectively) * Ctrl- and shift-click behave as default (dress-up and paste link, respectively)
* Recipes you do not yet know are highlighted in blue * Recipes you do not yet know are highlighted in blue
* Items you cannot use are highlighted in red * Items you cannot use are highlighted in red
* Search box to help you find that item you're after on a vendor with hundreds of items
h2. Un-features h2. Un-features
* No support for split-stack purchases, I'm not convinced it's needed. * No support for split-stack purchases, I'm not convinced it's needed.
* No search... yet
h2. Links h2. Links