View Single Post
05/29/14, 05:43 AM   #9
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Aicam View Post
Do something like the following and you will notice that the callback of the button has nothing to do with the action triggered with the keybind.
Lua Code:
  1. ZO_OptionsWindowResetToDefaultButton:SetCallback( function() d( "Hello World" ) end )
The only option i see is to hook into ZO_Dialogs_ShowDialog( name, ... ).
I just don't think this is a really good idea unless you know all possible dialog names.
It's true that code I have posted before did not store original callback, so it won't work the way we want. lyravega's code does not cause issues just because he calls ReloadUI() from the callback.

So I was digging around and I found that dialog displayed from the callback is "OPTIONS_RESET_TO_DEFAULTS" and from this dialog is called function ZO_OptionsWindow_LoadDefaults(). So maybe hook this function?

Lua Code:
  1. ZO_PreHook("ZO_OptionsWindow_LoadDefaults",
  2.    function(control)
  3.       if ZO_OptionsWindow.currentPanel == yourPanelId then
  4.          --your code
  5.          return true --true means that ZO_PreHook will not call original function
  6.       end
  7.       return false
  8.    end)
  Reply With Quote