WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Run a function when InterfaceOptionsFrame gets closed (https://www.wowinterface.com/forums/showthread.php?t=56951)

FranekW 01-05-19 08:36 AM

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

jlam 01-05-19 09:40 AM

Quote:

Originally Posted by FranekW (Post 331270)
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.

FranekW 01-05-19 11:31 AM

Quote:

Originally Posted by jlam (Post 331271)
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.

Kanegasi 01-05-19 07:07 PM

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.

FranekW 01-05-19 08:49 PM

Hey,

Thanks for your code. Ill try it tomorrow.

Id also have a go with the idea of a config as soon as I can sort out the dialog box.


All times are GMT -6. The time now is 12:33 AM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI