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 What am I doing wrong? |
"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 /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. :> |
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? |
Quote:
|
ReloadUI() is not a protected function, however it does require a hardware event.
|
Quote:
Quote:
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. |
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.
|
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).
|
Have you tried SendChatMessage("/console reloadui") yet?
|
Quote:
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 02:38 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI