View Single Post
07-24-10, 11:27 AM   #4
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
The actual change of which action is associated with an action button is handled via the function ActionButton_UpdateAction. The only way for non-Blizzard code to force a call of that (without taint) is via an action button's OnAttributeChanged script. So you need to make sure that you change a button's attribute (not just set it to the same value).

Looking at your CompactBars.lua and the code directly related to this:
Code:
actionbar:SetAttribute("_onstate-page", [[
	self:SetAttribute("actionpage", tonumber(newstate));
	ActionButtons = newtable( self:GetChildren() );
	for i, button in ipairs( ActionButtons ) do
		button:SetAttribute("touch", nil);
	end
]]);
RegisterStateDriver(actionbar, "page", "[bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; [bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9; [bonusbar:4] 10; [bonusbar:5] 11; 1");
for i = 1, 12 do
	local button = CreateFrame("CheckButton", "snkUI_CompactBarButton"..i, actionbar, "ActionBarButtonTemplate");
	button:SetID(i);
	button:SetAttribute("useparent-actionpage", true);
	button:SetPoint("TOPLEFT", actionbar, 0, 0);
end
I would make the following changes:
Code:
actionbar:SetAttribute("_onstate-page", [[
	newstate = tonumber(newstate)
	for i, button in ipairs( ActionButtons ) do
		button:SetAttribute('actionpage', newstate)
	end
]]);
for i = 1, 12 do
	local button = CreateFrame("CheckButton", "snkUI_CompactBarButton"..i, actionbar, "ActionBarButtonTemplate");
	button:SetID(i);
	button:SetPoint("TOPLEFT", actionbar, 0, 0);
end 
actionbar:Execute([[
	ActionButtons = newtable( self:GetChildren() );
]])
RegisterStateDriver(actionbar, "page", "[bonusbar:5] 11; [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; [bonusbar:1] 7; [bonusbar:2] 8; [bonusbar:3] 9; [bonusbar:4] 10; 1");
Note: I changed the order of a couple things for a reason.
  Reply With Quote