You can now click on labels to select/deselect addons

Wobin [05-15-14 - 15:06]
You can now click on labels to select/deselect addons
if you click on one addon, then shiftclick further down or up, all intervening addons will be selected/unselected
Filename
AddonClearer.lua
diff --git a/AddonClearer.lua b/AddonClearer.lua
index 95327a6..84c9a22 100644
--- a/AddonClearer.lua
+++ b/AddonClearer.lua
@@ -41,17 +41,47 @@ function AddonClearer:SetAddons(toDo)
 	SCENE_MANAGER:AddFragment(ADDONS_FRAGMENT)
 end

+local firstControl = nil
+
+function AddonClearer:MultiSelect(button)
+	if not IsShiftKeyDown() then firstControl = self return false end
+	if self ~= firstControl and IsShiftKeyDown() then
+		local firstRow = firstControl:GetParent().data
+		local currentRow = self:GetParent().data
+		local AddOnManager = GetAddOnManager()
+		local step = firstRow.sortIndex	- currentRow.sortIndex < 0 and 1 or -1
+		for i = firstRow.sortIndex, currentRow.sortIndex, step do
+			AddOnManager:SetAddOnEnabled(AddonClearer.ReverseLookup[i], firstRow.addOnEnabled)
+		end
+	end
+	return false
+end
+
 function AddonClearer:ShowPanel(...)
-	local a,b = ...
+	local _, a,b = ...
+
 	if not (a == 14 and b == 5) then return end
+
+	for i,control in ipairs(ZO_AddOnsList.activeControls) do
+		local name = control:GetNamedChild("Name")
+		local enabled = control:GetNamedChild("Enabled")
+		local enabledClick = enabled:GetHandler("OnClicked")
+		name:SetMouseEnabled(true)
+		name:SetHandler("OnMouseDown", function(self, button) AddonClearer.MultiSelect(enabled, button) enabledClick(enabled, button) end)
+		ZO_PreHookHandler(enabled, "OnClicked", function(...) AddonClearer.MultiSelect(...) return false end)
+	end
+
+	AddonClearer.ReverseLookup = {}

+	for i,v in ipairs(ZO_AddOnsList.data) do
+		AddonClearer.ReverseLookup[v.data.sortIndex] = v.data.index
+	end
 end

 function AddonClearer:Loaded(eventCode, addonName)
 	if(addonName ~= "AddonClearer") then return end
 	AddonClearer.settings  = ZO_SavedVars:NewAccountWide("AddonClearerSV", 1, nil, {savedSetup = {}})
-
-	EVENT_MANAGER:RegisterForEvent("AddonShowing", EVENT_ACTION_LAYER_PUSHED, function(...) AddonClearer:ShowPanel(...) end)
+	EVENT_MANAGER:RegisterForEvent("AddonClearerShowing", EVENT_ACTION_LAYER_PUSHED, function(...) AddonClearer:ShowPanel(...) end)
 end

 EVENT_MANAGER:RegisterForEvent("AddonClearerLoaded", EVENT_ADD_ON_LOADED, function(...) AddonClearer:Loaded(...) end)
\ No newline at end of file