Thread Tools Display Modes
05-27-19, 01:40 AM   #1
MinguasBeef
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: May 2019
Posts: 51
How to open addon interface options?

Edit: Shortly after making this post I found the answer. For anyone searching for the same thing, you just need to call
Code:
InterfaceOptionsFrame_OpenToCategory("ADDON NAME")
I made a panel and some options in the interface addon menu for my addon.

I can hit escape and access the addons menu from there, but I wanted to add a slash command to open up the menu automatically.

I've done this a long time ago and I forgot how I accomplished this. How would I open up the interface addon window and select a specific panel with LUA?

Last edited by MinguasBeef : 05-27-19 at 01:47 AM.
  Reply With Quote
05-27-19, 10:03 AM   #2
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
Quick note, there has been a long standing bug(?) that prevents that code from always opening to the addon. The work around I use is first calling InterfaceOptionsFrame_Show before opening the category.

Lua Code:
  1. InterfaceOptionsFrame_Show()
  2. InterfaceOptionsFrame_OpenToCategory("ADDON NAME")
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote
05-30-19, 12:37 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Or you can just open to the category twice.

This usually happens if your addon is not visible in the scrollframe list on the left.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
10-07-21, 08:32 AM   #4
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
Originally Posted by Seerah View Post
This usually happens if your addon is not visible in the scrollframe list on the left.
In Burning Crusade Classic, my addon isn't visible in the scrollframe list the first time I call:

Lua Code:
  1. InterfaceOptionsFrame_OpenToCategory("Skillet")
unless I open the panel and manually scroll to the page my addon is listed on. Other than changing my addon name to "ASkillet", is there anyway to force the scroll to happen, i.e.

Lua Code:
  1. InterfaceOptionsFrame_ScrollToCategory("Skillet")
  Reply With Quote
10-07-21, 10:30 AM   #5
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
Other idea.

Lua Code:
  1. local function ScrollToCategory(panelName)
  2.   local idx
  3.   for i,cat in ipairs(INTERFACEOPTIONS_ADDONCATEGORIES) do
  4.     if not cat.hidden then
  5.       idx=(idx or 0) + 1
  6.       if cat.name == panelName then
  7.         break
  8.       end
  9.     end
  10.   end
  11.   local numbuttons = #(InterfaceOptionsFrameAddOns.buttons)
  12.   if idx and numbuttons and idx > numbuttons then
  13.     local btnHeight = InterfaceOptionsFrameAddOns.buttons[1]:GetHeight()
  14.     InterfaceOptionsFrameAddOnsListScrollBar:SetValue((idx-numbuttons)*btnHeight)
  15.   end
  16. end

Then using as
Code:
ScrollToCategory("Skillet")
.
It might need to be called on next frame after the first InterfaceOptionsFrame_OpenToCategory("Skillet")

I'm sure someone will come up with a more elegant solution.

Last edited by Dridzt : 10-07-21 at 04:12 PM.
  Reply With Quote
10-09-21, 07:35 AM   #6
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
It works!

Lua Code:
  1. function Skillet:ShowOptions()
  2.     InterfaceOptionsFrame_Show()
  3.     ScrollToCategory("Skillet")
  4.     InterfaceOptionsFrame_OpenToCategory("Skillet")
  5. end

Thank you!
  Reply With Quote
10-09-21, 07:42 AM   #7
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
Originally Posted by bsmorgan View Post
It works!

Lua Code:
  1. function Skillet:ShowOptions()
  2.     InterfaceOptionsFrame_Show()
  3.     ScrollToCategory("Skillet")
  4.     InterfaceOptionsFrame_OpenToCategory("Skillet")
  5. end

Thank you!
If you want it to "always work" and not have to complicate the method you could add a
Code:
InterfaceOptionsFrameAddOnsListScrollBar:SetValue(0)
to reset the addon list to the top as it retains the last selection for the session.

That would make it more generic so it works for addons towards the top of the list when the last addon selected was a the bottom (list is already scrolled down from a previous user action)
  Reply With Quote
10-09-21, 08:25 AM   #8
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
I modified it a little bit. Since Skillet has 3 sub-categories and as written, it always puts the main category at the bottom. I added an offset value so that once expanded, Skillet and its sub-categories were always on the screen.

Lua Code:
  1. local function ScrollToCategory(panelName,offset)
  2.     local idx = 0
  3.     InterfaceOptionsFrameAddOnsListScrollBar:SetValue(0)
  4.     for i,cat in ipairs(INTERFACEOPTIONS_ADDONCATEGORIES) do
  5.         if not cat.hidden then
  6.             idx = idx + 1
  7.             if cat.name == panelName then
  8.                 break
  9.             end
  10.         end
  11.     end
  12.     local numbuttons = #(InterfaceOptionsFrameAddOns.buttons)
  13.     if idx and numbuttons and idx > numbuttons then
  14.         local btnHeight = InterfaceOptionsFrameAddOns.buttons[1]:GetHeight()
  15.         InterfaceOptionsFrameAddOnsListScrollBar:SetValue((offset+idx-numbuttons)*btnHeight)
  16.     end
  17. end

I guess the code should worry about setting a value that exceeds the maximum.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to open addon interface options?

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