-
Posted by bdrummer on Tue, 07 Sep 2010 04:11:44
For an addon I am writing, I need to be able to disable a frame that inherits UIDropDownMenuTemplate whenever a checkbox is unchecked. I have tried everything from Frame:Disable() to trying to disable the DropDownMenu button itself. I want it to look like the Target of Target DropDownMenu in the Combat panel of Interface Options. If you uncheck the checkbox above the Target of Target DropDownMenu, you can see what it looks like disabled. That is exactly what I want mine to look like. Any help will be greatly appreciated.
-bdrummer
-
Posted by jnwhiteh on Tue, 07 Sep 2010 07:06:54
The best way is to look at the code and see what it does. The XML can be found in InterfaceOptionsPanels.xml and some of the associated Lua code in InterfaceOptionsPanels.lua. The button in the UIDropDownMenuTemplate does have a DisabledTexture so it should just be a matter of disabling the button, possibly.
What I believe is actually happening here is that the check button is calling InterfaceOptionsPanelCheckButtonUpdate, and if you look at this function, it goes through all dependent controls and disables them. You can also see in the TOTDropDown that it registers as a dependent control of that checkbox:
BlizzardOptionsPanel_SetupDependentControl(InterfaceOptionsCombatPanelTargetOfTarget, self);
You should be able to re-use this sort of thing, without re-using this specific function, since its designed for the Blizzard options, and requires specific variables to be set, to take care of disabling your menu.
In reality, what is happening is this:
control.Disable = function (self) getmetatable(self).__index.Disable(self) _G[self:GetName().."Text"]:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b) end; control.Enable = function (self) getmetatable(self).__index.Enable(self) _G[self:GetName().."Text"]:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b) end;
Then those functions are used.
-
Posted by bdrummer on Tue, 07 Sep 2010 23:37:07
I have tried creating a function:
SM_OptionsPanel_SetupDisabled(control)
control.Disable = function (self) getmetatable(self).__index.Disable(self) _G[self:GetName().."Text"]:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b) end
end
and then use
menuName:Disable();
in another function to see if it would work with unfortunate results... I can see all of the cvar and uvar variables that Blizzard uses but I have no idea how I would implement those. How exactly would I disable the menu button itself if its name is "UIDropDownMenuTemplateButton" (looking at UIDropDownMenuTemplates.xml)?
-
Posted by bdrummer on Wed, 08 Sep 2010 00:41:23
Ok, after looking at blizzards function
BlizzardOptionsPanel_SetupDependantControl(dependancy, control)
I was able to figure out that it uses the function
control.Disable = function (self) UIDropDownMenu_DisableDropDown(self) end;
to disable the drop down menu. After implementing my own function and using
UIDropDownMenu_DisableDropDown(self)
I was able to disable my drop down menu successfully.The blizzard function mentioned above I found in 'OptionsPanelTemplates.lua'. Now I am going to create a function similar to blizzards so unchecking the check button will disable the menu. Thank you jnwhiteh for your help and pointing me in the right direction.
-
Posted by jnwhiteh on Wed, 08 Sep 2010 08:36:55
Glad you figured it out. Looking at Blizzard's code is always the right answer =)
-
Posted by jnwhiteh on Wed, 08 Sep 2010 08:36:55
Glad you figured it out. Looking at Blizzard's code is always the right answer =)