WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Reload UI with kgPanels button (https://www.wowinterface.com/forums/showthread.php?t=42109)

Smashbolt 12-13-11 08:49 PM

Reload UI with kgPanels button
 
I've got a couple of ShadowedUF profiles I switch between frequently, and I decided to make a button to do it for me. Problem is, for whatever reason, when I switch the profile, it comes out... wrong. Textures are broken, positioning is all wacky.

If I reload UI, the unit frames fix themselves. I wanted my button to do the reload for me after setting the profile, but it doesn't seem to do anything... Here's my onclick handler:

Code:

if pressed then
    local run ShadowUF.db:SetProfile("BG40")
    local run ReloadUI()
end

I've tried just ReloadUI(), and even SendChatMessage("/reload ui") and all of them just do nothing.

What am I doing wrong?

Taryble 12-13-11 09:41 PM

"local" is a definition - whether the function or variable is Global or is only accessible from inside the current script.

"/run" is used when running lua script in a macro.

Neither one is actually needed here, as far as I know.

Code:

if pressed then
  ShadowUF.db:SetProfile("BG40")
  ReloadUI()
end

Now, I'm not sure if this will actually work. Does
/run ShadowUF.db:SetProfile("BG40")
swap your profile properly? If so, then the above code should work. If it doesn't, it's out of my ability to fix. :>

Smashbolt 12-13-11 09:56 PM

Sorry, I was a bit unclear there.

I tried the code as I'd written in my OP, the code you suggested (without "local run"), and because I saw it mentioned somewhere, I tried replacing the third line with SendChatMessage("/reload ui").

None of them work.

The ShadowedUF profile change does happen in all cases though, so I know the click handler is active. It's just the UI reload that never happens.

I read in the API reference that ReloadUI() is a protected function. I'd think that shouldn't matter since it's an onclick, but is it possible that kgPanels interferes with it somehow?

Nibelheim 12-13-11 11:18 PM

Quote:

Originally Posted by Smashbolt (Post 249426)
Sorry, I was a bit unclear there.

I tried the code as I'd written in my OP, the code you suggested (without "local run"), and because I saw it mentioned somewhere, I tried replacing the third line with SendChatMessage("/reload ui").

None of them work.

The ShadowedUF profile change does happen in all cases though, so I know the click handler is active. It's just the UI reload that never happens.

I read in the API reference that ReloadUI() is a protected function. I'd think that shouldn't matter since it's an onclick, but is it possible that kgPanels interferes with it somehow?

Unless the kgPanels frame is a secure frame, which it isn't, then it won't work. Do you have Lua Errors turned off? The UI usually pops up with an error when trying to execute protected functions from a non-secure source. Whenever I need an on-click ReloadUI I have to use a secure frame.

Seerah 12-14-11 11:03 AM

ReloadUI() is not a protected function, however it does require a hardware event.

Smashbolt 12-14-11 12:50 PM

Quote:

Originally Posted by Seerah (Post 249476)
ReloadUI() is not a protected function, however it does require a hardware event.

The WoWPedia page for ReloadUI() says
Quote:

This function is protected, and may only be called in response to hardware event.
Different definitions of protected? Or is the WoWPedia page wrong?

Either way, it didn't throw any Lua errors - I definitely had those turned on.

I ended up doing it the "hard way" and just wrote a little addon that makes a standard UI button that calls that script on click, and that works.

Nibelheim 12-14-11 02:03 PM

It's a strange one. The function itself probably isn't protected as you can call it in non-secure code as long as the hardware event was triggered from a secure frame.

Torhal 12-20-11 06:53 AM

Protected and Secure are two separate things; protected functions require a hardware event and secure functions can only be performed by the default UI or by using secure state drivers (which is limited for AddOn functionality compared to what the default UI is allowed to do).

Taffu 12-20-11 08:53 AM

Have you tried SendChatMessage("/console reloadui") yet?

Smashbolt 12-20-11 03:05 PM

Quote:

Originally Posted by Taffu (Post 249844)
Have you tried SendChatMessage("/console reloadui") yet?

Yep. It led to me saying "/console reloadui" in the /say channel.

It's all good though. I understand why it didn't work, and I was able to make it work for my own frames spawned from Lua (instead of through kgPanels), which was my eventual goal anyway.


All times are GMT -6. The time now is 07:50 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI