Below, I'll paste a code block that might help you. I'll add comments to show what I am doing, and why in that block.
Lua Code:
local function QB_SettingsMenu()
--this is my function that sets up the settings menu
local LAM = LibStub:GetLibrary( "LibAddonMenu-1.0" )
local QB_SettingsPanelID = LAM:CreateControlPanel( "QB_Config", "|cFFD700Quest Buddy|r" )
--here I define the panel ID
local defaultText = ZO_OptionsWindowResetToDefaultButtonNameLabel:GetText()
local applyText = ZO_OptionsWindowApplyButtonNameLabel:GetText()
--these two locals are necessary if you are going to change the default texts
ZO_PreHook("ZO_OptionsWindow_ChangePanels", function(panel)
if (panel == QB_SettingsPanelID) then
ZO_OptionsWindowResetToDefaultButton:SetHidden(false)
--I'd like to use this apply button as well
ZO_OptionsWindowResetToDefaultButton:SetKeybindEnabled(false)
--this has no effect for some reason, need to look a bit more for this
ZO_OptionsWindowResetToDefaultButtonKeyLabel:SetHidden(true)
--since above has no effect, we hide the button here
ZO_OptionsWindowResetToDefaultButtonNameLabel:SetText("Reset to Defaults")
--we change text with this if we so desire
--same stuff goes for the apply button as well which you can see below
ZO_OptionsWindowApplyButton:SetHidden(false)
ZO_OptionsWindowApplyButton:SetKeybindEnabled(false)
ZO_OptionsWindowApplyButtonKeyLabel:SetHidden(true)
ZO_OptionsWindowApplyButtonNameLabel:SetText("Apply Changes")
--below is the callback function for apply button
--which is merely a ReloadUI for my add-on
ZO_OptionsWindowApplyButton:SetCallback(function()
ReloadUI()
end)
--below is the function for the defaults button
--which resets everything to the default values
ZO_OptionsWindowResetToDefaultButton:SetCallback(function()
for variable, value in next, QB_defaults do
QB_vars[variable] = value
end
ReloadUI()
end)
--the ELSE below is IMPORTANT if you are changing the texts and/or hiding the keybind icons
--what this part does is just reverting everything back to "vanilla"
else
ZO_OptionsWindowResetToDefaultButton:SetKeybindEnabled(true)
ZO_OptionsWindowResetToDefaultButtonKeyLabel:SetHidden(false)
ZO_OptionsWindowResetToDefaultButtonNameLabel:SetText(defaultText)
--defaultText is used here, which was stored prior to the change
ZO_OptionsWindowApplyButton:SetKeybindEnabled(true)
ZO_OptionsWindowApplyButtonKeyLabel:SetHidden(false)
ZO_OptionsWindowApplyButtonNameLabel:SetText(applyText)
end
end)
local QB_Main = LAM:AddHeader(QB_SettingsPanelID, "QB_Description", "")
--we need to define a variable name for a header, preferably for the first one
--because LAM hides these reset buttons while setting up headers, for some reason
--and then sets handlers, which hides the buttons
QB_Main:SetHandler("OnShow", function() return end)
QB_Main:SetHandler("OnHide", function() return end)
--these two above are necessary, we are basically overriding what LAM is doing here
--if you don't do this, the reset button will stay hidden
... --rest of the menu stuff goes here
Result:
For vanilla menus, the texts will be reverted back, as well as the hidden keybind buttons. For other menus created with LAM, they will keep their hidden stuff. As I've said above, keybinds cannot be disabled for some reason (try pressing "Apply" key or "Defaults" key while navigating a LAM menu); only their icons are disabled, not their functions, I'm sure Seerah will find the reason soon enough with 2.0 or something
If anyone know how to change a keybinding via API, then changing that keybinding temporarily or unbinding would help (run "/script d(ZO_Keybindings_GetBindingStringFromAction("OPTIONS_APPLY_CHANGES"))" this is the problem). Also this code above has one problem; when you open your add-on menu, it will also override vanilla stuff, so lets say you changed defaults button and now it simply just runs a d() function, after looking at your menu then vanilla menus and clicking defaults button will also run that function.
Off-topic, for some reason LAM tries to show/hide the reset buttons under "AddHeader". It has handlers for OnShow and OnHide, but they do not work as intended I believe. I'll contact Seerah about these, but for now this is more or less how you can modify the vanilla buttons for your options menu that is created with LAM.