1. #1
    Deleted

    KgPanel issue with hiding a panel.

    Hey, I have this button my on UI which changes its alpha to 1 if you hold the Alt key (while out of combat) and its onClick script only works if you hold the alt key down as well. My problem however is that the panel blocks the Target of Target Frame and when you are not holding alt down it blocks interaction with mouse clicks as the frame is not disabled/hidden, its just invisible.



    If I change SetAlpha(1) and SetAlpha(0) to Hide() and Show() then holding the Alt key no longer shows it so I can't use that.

    This is the image of what I mean and below is my onUpdate Script:



    Code:
    if kgPanels:FetchFrame("BottomBars"):IsVisible() then      
    self:Show()
    else
    self:Hide()
    end  
    
    if IsAltKeyDown() and not IsControlKeyDown() and not IsShiftKeyDown() then
    self:SetAlpha(1)
    else
    self:SetAlpha(0)
    end
    If anyone knows anything that could help me out then I would appreciate the help Thank you for reading!

  2. #2
    Deleted
    Don't use OnUpdate, that's redundant. Register for MODIFIER_STATE_CHANGED, PLAYER_REGEN_ENABLED and PLAYER_REGEN_DISABLED. Something like this should work:

    OnLoad
    Code:
    self:RegisterEvent("MODIFIER_STATE_CHANGED")
    self:RegisterEvent("PLAYER_REGEN_ENABLED")
    self:RegisterEvent("PLAYER_REGEN_DISABLED")
    function self:UpdateVisibility()
        if IsAltKeyDown() and (not IsControlKeyDown()) and (not IsShiftKeyDown()) and (not self.combatState) then
            self:Show()
        else
            self:Hide()
        end
    end
    OnEvent
    Code:
    if event == "PLAYER_REGEN_ENABLED" then
        self.combatState = false
    elseif event == "PLAYER_REGEN_DISABLED" then
        self.combatState = true
    end
    self:UpdateVisibility()
    Note: I'm not sure how to get the event name in kgPanels. I'm assuming the loadstring is either wrapped into a function(event) or setfenv()'d to have 'event'. If it's not named 'event', check how it is named, then update accordingly.

  3. #3
    Deleted
    Thank you. You taught me a lot with that and I won't use OnUpdate again
    That works perfectly!

    ---------- Post added 2013-01-19 at 10:54 AM ----------

    I am having a few issues with this. The first is that when I log on I get a lua error which I've linked at the bottom of this post. Another is that when I log on, the panel is showing when I am not holding down the Alt key which is most likely because of the lua error. The other problem is that I had to reuse the OnUpdate code which you said was redundant because I have two panels and the both should only show with the Alt key if their own targeted panel is showing: "if kgPanels:FetchFrame("BottomBars2"):IsVisible() then...". It is hard to explain without using my UI but I hope this makes sense. Sorry for the overwhelming amount of code that follows this. It is just the best way to explain my problem. My lua skills are poor so I'm sure there is a lot wrong with what I'm doing. Thank you for your time if anyone looks through this.


    First Panel:
    OnLoad:
    Code:
    self:RegisterEvent("MODIFIER_STATE_CHANGED")
    self:RegisterEvent("PLAYER_REGEN_ENABLED")
    self:RegisterEvent("PLAYER_REGEN_DISABLED")
    
    if kgPanels:FetchFrame("BottomBars"):IsVisible() then                          
    	function self:UpdateVisibility()
    		if IsAltKeyDown() and (not IsControlKeyDown()) and (not IsShiftKeyDown()) and (not self.combatState) then
    			self:Show()
    		else
    			self:Hide()
    		end
    	end            
    else
    self:Hide()
    end
    OnEvent:
    Code:
    if event == "PLAYER_REGEN_ENABLED" then
        self.combatState = false
    elseif event == "PLAYER_REGEN_DISABLED" then
        self.combatState = true
    end
    self:UpdateVisibility()
    OnUpdate:
    Code:
    if kgPanels:FetchFrame("BottomBars"):IsVisible() then      
    self:Show()
    else
    self:Hide()
    end

    My Second Panel:
    OnLoad:
    Code:
    self:RegisterEvent("MODIFIER_STATE_CHANGED")
    self:RegisterEvent("PLAYER_REGEN_ENABLED")
    self:RegisterEvent("PLAYER_REGEN_DISABLED")
     
    if kgPanels:FetchFrame("BottomBars2"):IsVisible() then                          
    	function self:UpdateVisibility()
    		if IsAltKeyDown() and (not IsControlKeyDown()) and (not IsShiftKeyDown()) and (not self.combatState) then
    			self:Show()
    		else
    			self:Hide()
    		end
    	end                  
    else
    self:Hide()
    end
    OnEvent:
    Code:
    if event == "PLAYER_REGEN_ENABLED" then
        self.combatState = false
    elseif event == "PLAYER_REGEN_DISABLED" then
        self.combatState = true
    end
    self:UpdateVisibility()
    OnUpdate:
    Code:
    if kgPanels:FetchFrame("BottomBars"):IsVisible() then      
    self:Hide()
    else
    self:Show()
    end

    Also I am getting the following lua error when I press Alt:
    Code:
    Message: [string "Retract_OnEvent"]:6: attempt to call method 'UpdateVisibility' (a nil value)
    Time: 01/19/13 10:48:31
    Count: 14
    Stack: [string "Retract_OnEvent"]:6: in function <[string "Retract_OnEvent"]:1>
    
    Locals: self = kgPanel3 {
     0 = <userdata>
     _backdrop_options = <table> {
     }
     _GetBackdropColor = <function> defined =[C]:-1
     SetBackdropGradientAlpha = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:513
     _SetBackdrop = <function> defined =[C]:-1
     GetBackdropBorderSection = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:141
     GetBackdropColor = <function> defined =[C]:-1
     _backdrop = <unnamed> {
     }
     _GetBackdropBorderColor = <function> defined =[C]:-1
     SetBackdropBorderColor = <function> defined =[C]:-1
     bg = <unnamed> {
     }
     missing_anchor_at_load = false
     missing_parent_at_load = false
     scripts_loaded = false
     SetBackdropBorderGradientAlpha = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:546
     GetBackdropBackground = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:134
     text = <unnamed> {
     }
     SetBackdrop = <function> defined =[C]:-1
     BorderTextureFunction = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:122
     SetBackdropColor = <function> defined =[C]:-1
     GetBackdropBorderColor = <function> defined =[C]:-1
     _GetBackdrop = <function> defined =[C]:-1
     GetBackdrop = <function> defined =[C]:-1
     SetBackdropBorderGradient = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:520
     _SetBackdropBorderColor = <function> defined =[C]:-1
     _SetBackdropColor = <function> defined =[C]:-1
     SetBackdropGradient = <function> defined @Interface\AddOns\kgPanels\Libs\LibBackdrop-1.0\LibBackdrop-1.0.lua:506
    }
    event = "MODIFIER_STATE_CHANGED"
    arg1 = "LALT"
    arg2 = 0
    arg3 = nil
    arg4 = nil
    arg5 = nil
    arg6 = nil
    arg7 = nil
    arg8 = nil
    arg9 = nil
    arg10 = nil
    kgPanels = <table> {
     SetDefaultModuleLibraries = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:383
     FetchFont = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:382
     SetupScript = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:1017
     Enable = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:315
     RegisterChatCommand = <function> defined @Interface\AddOns\Bagnon\libs\AceConsole-3.0\AceConsole-3.0.lua:85
     EnableModule = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:348
     modules = <table> {
     }
     GetModule = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:231
     IterateEmbeds = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:458
     ResetFont = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:999
     defaultModuleLibraries = <table> {
     }
     eframe = kgPanels_Dep_Frame {
     }
     UnregisterChatCommand = <function> defined @Interface\AddOns\Bagnon\libs\AceConsole-3.0\AceConsole-3.0.lua:111
     Printf = <function> defined @Interface\AddOns\Bagnon\libs\AceConsole-3.0\AceConsole-3.0.lua:69
     angles = <table> {
     }
     GetName = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:300
     AddMissingMedia = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:467
     ReParent = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:721
     name = "kgPanels"
     FetchArt = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:379
     IsEnabled = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:467
     orderedModules = <table> {
     }
     CommandLine = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:616
     DisableModule = <function> defined @Interface\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:366
     active = "Main"
     RemoveFrame = <function> defined @Interface\AddOns\kgPanels\kgPanels.lua:736
     parents = <table> {
     }
     GetArgs = <function> defined @Interface\AddOn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •