AckisRecipeList:
zhinjio [11-20-08 - 21:06]
AckisRecipeList:
- empty button click thinger fix
- NOT dry coded
diff --git a/ARLFrame.lua b/ARLFrame.lua
index b4d547c..6ade685 100644
--- a/ARLFrame.lua
+++ b/ARLFrame.lua
@@ -2332,102 +2332,107 @@ end
function addon.RecipeItem_OnClick(button)
local clickedIndex = addon.RecipeListButton[button].sI
- local isRecipe = DisplayStrings[clickedIndex].IsRecipe
- local isExpanded = DisplayStrings[clickedIndex].IsExpanded
- local dString = DisplayStrings[clickedIndex].String
- local clickedSpellIndex = DisplayStrings[clickedIndex].sID
- local traverseIndex = 0
- -- First, check if this is a "modified" click, and react appropriately
- if (IsShiftKeyDown()) then
+ -- Don't do anything if they've clicked on an empty button
+ if ( clickedIndex ~= nil ) then
+ local isRecipe = DisplayStrings[clickedIndex].IsRecipe
+ local isExpanded = DisplayStrings[clickedIndex].IsExpanded
+ local dString = DisplayStrings[clickedIndex].String
+ local clickedSpellIndex = DisplayStrings[clickedIndex].sID
+ local traverseIndex = 0
- local itemID = recipeDB[clickedSpellIndex]["ItemID"]
- local _, itemLink = GetItemInfo(itemID)
+ -- First, check if this is a "modified" click, and react appropriately
+ if (IsShiftKeyDown()) then
- if (itemLink) then
+ local itemID = recipeDB[clickedSpellIndex]["ItemID"]
+ local _, itemLink = GetItemInfo(itemID)
- ChatFrameEditBox:Insert(itemLink)
+ if (itemLink) then
- else
+ ChatFrameEditBox:Insert(itemLink)
- addon:Print(L["NoItemLink"])
+ else
- end
+ addon:Print(L["NoItemLink"])
- elseif (IsControlKeyDown()) then
+ end
- ChatFrameEditBox:Insert(recipeDB[clickedSpellIndex]["RecipeLink"])
+ elseif (IsControlKeyDown()) then
- elseif (IsAltKeyDown()) then
+ ChatFrameEditBox:Insert(recipeDB[clickedSpellIndex]["RecipeLink"])
- -- Code needed here to insert this item into the "Ignore List"
- addon:ToggleExcludeRecipe(clickedSpellIndex)
- ReDisplay()
+ elseif (IsAltKeyDown()) then
- else
+ -- Code needed here to insert this item into the "Ignore List"
+ addon:ToggleExcludeRecipe(clickedSpellIndex)
+ ReDisplay()
- -- three possibilities here
- -- 1) We clicked on the recipe button on a closed recipe
- -- 2) We clicked on the recipe button of an open recipe
- -- 3) we clicked on the expanded text of an open recipe
- if (isRecipe) then
+ else
- if (isExpanded) then
+ -- three possibilities here
+ -- 1) We clicked on the recipe button on a closed recipe
+ -- 2) We clicked on the recipe button of an open recipe
+ -- 3) we clicked on the expanded text of an open recipe
+ if (isRecipe) then
- -- get rid of our expanded lines
- traverseIndex = clickedIndex + 1
+ if (isExpanded) then
- while (DisplayStrings[traverseIndex].IsRecipe == false) do
+ -- get rid of our expanded lines
+ traverseIndex = clickedIndex + 1
- tremove(DisplayStrings, traverseIndex)
+ while (DisplayStrings[traverseIndex].IsRecipe == false) do
+
+ tremove(DisplayStrings, traverseIndex)
+
+ -- if this is the last entry in the whole list, we should break out
+ if not DisplayStrings[traverseIndex] then
- -- if this is the last entry in the whole list, we should break out
- if not DisplayStrings[traverseIndex] then
+ break
- break
+ end
end
- end
+ DisplayStrings[clickedIndex].IsExpanded = false
- DisplayStrings[clickedIndex].IsExpanded = false
+ else
- else
+ -- add in our expanded lines
+ expandEntry(clickedIndex)
+ -- set our current recipe to expanded
+ DisplayStrings[clickedIndex].IsExpanded = true
- -- add in our expanded lines
- expandEntry(clickedIndex)
- -- set our current recipe to expanded
- DisplayStrings[clickedIndex].IsExpanded = true
+ end
- end
+ else
- else
+ -- this inherently implies that we're on an expanded recipe
+ -- first, back up in the list of buttons until we find our recipe line
+ traverseIndex = clickedIndex - 1
- -- this inherently implies that we're on an expanded recipe
- -- first, back up in the list of buttons until we find our recipe line
- traverseIndex = clickedIndex - 1
+ while (DisplayStrings[traverseIndex].IsRecipe == false) do
- while (DisplayStrings[traverseIndex].IsRecipe == false) do
+ traverseIndex = traverseIndex - 1
- traverseIndex = traverseIndex - 1
+ end
- end
+ -- unexpand it
+ DisplayStrings[traverseIndex].IsExpanded = false
+ -- now remove the expanded lines until we get to a recipe again
+ traverseIndex = traverseIndex + 1
- -- unexpand it
- DisplayStrings[traverseIndex].IsExpanded = false
- -- now remove the expanded lines until we get to a recipe again
- traverseIndex = traverseIndex + 1
+ while (DisplayStrings[traverseIndex].IsRecipe == false) do
- while (DisplayStrings[traverseIndex].IsRecipe == false) do
+ tremove(DisplayStrings, traverseIndex)
- tremove(DisplayStrings, traverseIndex)
+ end
end
- end
+ -- finally, call our scrollframe updater
+ RecipeList_Update()
- -- finally, call our scrollframe updater
- RecipeList_Update()
+ end
end