Thread Tools Display Modes
12-13-11, 08:49 PM   #1
Smashbolt
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
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?
  Reply With Quote
12-13-11, 09:41 PM   #2
Taryble
A Molten Giant
 
Taryble's Avatar
Join Date: Jan 2009
Posts: 811
"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. :>
__________________
-- Taryble
  Reply With Quote
12-13-11, 09:56 PM   #3
Smashbolt
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
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?
  Reply With Quote
12-13-11, 11:18 PM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Smashbolt View Post
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.
  Reply With Quote
12-14-11, 11:03 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
ReloadUI() is not a protected function, however it does require a hardware event.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-14-11, 12:50 PM   #6
Smashbolt
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
Originally Posted by Seerah View Post
ReloadUI() is not a protected function, however it does require a hardware event.
The WoWPedia page for ReloadUI() says
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.
  Reply With Quote
12-14-11, 02:03 PM   #7
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
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.
  Reply With Quote
12-20-11, 06:53 AM   #8
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
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).
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
12-20-11, 08:53 AM   #9
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
Have you tried SendChatMessage("/console reloadui") yet?
  Reply With Quote
12-20-11, 03:05 PM   #10
Smashbolt
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
Originally Posted by Taffu View Post
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.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Reload UI with kgPanels button

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