Quantcast
gray out a setting - WoWInterface
Thread Tools Display Modes
11-27-22, 12:43 AM   #1
sirpucna
A Fallenroot Satyr
Join Date: Nov 2016
Posts: 29
gray out a setting

looking for a way to gray out a setting in Blizzards new DF setting panel.
In the past I did:
Code:
InterfaceOptionsNamesPanelUnitNameplatesMakeLarger.setFunc = function() end
InterfaceOptionsNamesPanelUnitNameplatesMakeLarger:Hide()
  Reply With Quote
11-27-22, 01:29 PM   #2
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 305
The new settings UI is quite complicated. It reuses elements like sliders and drop downs on every page, giving it different labels. So you have to search for the one you want to disable and re-enable it when the page changes. Here is how I disabled the "Mouse Look Speed" slider with my addon DynamicCam. (The label text constant MOUSE_LOOK_SPEED by which I recognize the element could be found here: https://www.townlong-yak.com/framexm...balStrings.lua)

Lua Code:
  1. local mouseLookSpeedSlider = nil
  2. local MouseLookSpeedSliderOrignialTooltipEnter = nil
  3. local MouseLookSpeedSliderOrignialTooltipLeave = nil
  4.  
  5. hooksecurefunc(SettingsPanel.Container.SettingsList.ScrollBox, "Update", function(self)
  6.  
  7.   local foundMouseLookSpeedSlider = false
  8.   local children = { SettingsPanel.Container.SettingsList.ScrollBox.ScrollTarget:GetChildren() }
  9.   for i, child in ipairs(children) do
  10.     if child.Text then
  11.       if child.Text:GetText() == MOUSE_LOOK_SPEED then
  12.         -- print("Found", child.Text:GetText(), MOUSE_LOOK_SPEED)
  13.         foundMouseLookSpeedSlider = true
  14.  
  15.         if not mouseLookSpeedSlider then
  16.           -- print("Disabling slider")
  17.           mouseLookSpeedSlider = child.SliderWithSteppers
  18.  
  19.           if not MouseLookSpeedSliderOrignialTooltipEnter then
  20.             MouseLookSpeedSliderOrignialTooltipEnter = mouseLookSpeedSlider.Slider:GetScript("OnEnter")
  21.             MouseLookSpeedSliderOrignialTooltipLeave = mouseLookSpeedSlider.Slider:GetScript("OnLeave")
  22.           end
  23.  
  24.           -- Change tooltip.
  25.           mouseLookSpeedSlider.Slider:SetScript("OnEnter", function(self)
  26.             GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 0, 0)
  27.             GameTooltip:AddLine("|cFFFF0000Disabled!|r", _, _, _, true)
  28.             GameTooltip:AddLine("Your Addon DynamicCam lets you adjust horizontal and vertical mouse look speed individually! Just go to the \"Mouse Look\" settings of DynamicCam to make the adjustments there.", _, _, _, true)
  29.             GameTooltip:Show()
  30.           end)
  31.           mouseLookSpeedSlider.Slider:SetScript("OnLeave", function(self)
  32.             GameTooltip:Hide()
  33.           end)
  34.         end
  35.  
  36.         -- Got to make sure, the slider stays disabled.
  37.         if mouseLookSpeedSlider.Slider:IsEnabled() then
  38.           mouseLookSpeedSlider:SetEnabled_(false)
  39.         end
  40.  
  41.         break
  42.       end
  43.     end
  44.   end
  45.  
  46.   -- If the slider is used for something else and we have changed it before, undo the change.
  47.   if mouseLookSpeedSlider and not foundMouseLookSpeedSlider then
  48.     -- print("Re-enabling slider")
  49.     mouseLookSpeedSlider.Slider:SetScript("OnEnter", MouseLookSpeedSliderOrignialTooltipEnter)
  50.     mouseLookSpeedSlider.Slider:SetScript("OnLeave", MouseLookSpeedSliderOrignialTooltipLeave)
  51.     if not mouseLookSpeedSlider.Slider:IsEnabled() then
  52.       mouseLookSpeedSlider:SetEnabled_(true)
  53.     end
  54.     mouseLookSpeedSlider = nil
  55.   end
  56.  
  57. end)
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
11-27-22, 06:39 PM   #3
sirpucna
A Fallenroot Satyr
Join Date: Nov 2016
Posts: 29
perfect!
located the string I wanted
swapped out child.SliderWithSteppers for child.DropDown, changed .Slider to .Button and all is well.

much appreciated.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » gray out a setting

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off