Thread Tools Display Modes
01-05-19, 08:36 AM   #1
FranekW
A Cyclonian
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 44
Run a function when InterfaceOptionsFrame gets closed

I have an addon that hides a part of UI under certain conditions with an option to simulate those conditions and test how UI changes. Everything can be done inside the InterfaceOptionsFrame. One problem is that it is possible to close the frame when options remain in simulation state and then the UI remains altered. I would like to run a small function whenever interface frame is closed so my addon can restore the default UI state.

The addon is totally based on Ace libraries. As such, I have Ace-Addon, Ace-Event to register and handle all events, and Ace-Config including Ace-ConfigDialog to create InterfaceOptionsFrame. I can't find anything on hooking the Interface Frame when it gets shown or hidden. Is possible?

Thanks
  Reply With Quote
01-05-19, 09:40 AM   #2
jlam
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 29
Originally Posted by FranekW View Post
I have an addon that hides a part of UI under certain conditions with an option to simulate those conditions and test how UI changes. Everything can be done inside the InterfaceOptionsFrame. One problem is that it is possible to close the frame when options remain in simulation state and then the UI remains altered. I would like to run a small function whenever interface frame is closed so my addon can restore the default UI state.

The addon is totally based on Ace libraries. As such, I have Ace-Addon, Ace-Event to register and handle all events, and Ace-Config including Ace-ConfigDialog to create InterfaceOptionsFrame. I can't find anything on hooking the Interface Frame when it gets shown or hidden. Is possible?

Thanks
As an alternative that many addons use that have a "configuration mode", you can create a dialog button on the screen while in configuration mode that cancels the mode.
  Reply With Quote
01-05-19, 11:31 AM   #3
FranekW
A Cyclonian
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 44
Originally Posted by jlam View Post
As an alternative that many addons use that have a "configuration mode", you can create a dialog button on the screen while in configuration mode that cancels the mode.
I see. Thanks for a good suggestion.

EDIT.

I tried to make a dialog box but I stuck again -,- As I use Ace3 I would like to avoid native LUA functions. I tried to follow suggestions on Ace3 website and create option table. The table would then be used to register a new dialog box but it's not clear how to do that.

I have a table like this:

Lua Code:
  1. -- dialog box
  2. local dialogBox = {
  3.     type = "group",
  4.     name = "Configure mode",
  5.     args = {
  6.         desc = {
  7.             type = "description",
  8.             order = 1,
  9.             name = "You are in the configure mode.",
  10.         },
  11.         exitmode = {
  12.             name = "Exit",
  13.             desc = "Press button to exit configure mode.",
  14.             order = 10,
  15.             type = "execute",
  16.             func = "resetAlphas",
  17.         },
  18.     },
  19. }

I can't find how to register this dialog, how to open it and how to respond when it is closed. Hope someone can help. Thanks.

Last edited by FranekW : 01-05-19 at 08:45 PM.
  Reply With Quote
01-05-19, 07:07 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
To answer your original question, you can hook the Interface Options Frame OnHide script/widget:

Lua Code:
  1. InterfaceOptionsFrame:HookScript("OnHide", function()
  2.     -- do stuff
  3. end)

I use this to get around taints involved with Blizzard's provided "cancel" function in the options api.
  Reply With Quote
01-05-19, 08:49 PM   #5
FranekW
A Cyclonian
 
FranekW's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 44
Hey,

Thanks for your code. I’ll try it tomorrow.

I’d also have a go with the idea of a config as soon as I can sort out the dialog box.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Run a function when InterfaceOptionsFrame gets closed

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