Thread Tools Display Modes
08-20-10, 11:15 PM   #1
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
Hooking TimeManagerClockButton

Is there a way for me to hook the TimeManagerClockButton and add some text to it? I'm trying to add the date aswell as the time with seconds.

Code:
date("%d/%m - %H:%M:%S")
__________________

  Reply With Quote
08-21-10, 05:53 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Code:
local addon = CreateFrame('Frame')
addon:RegisterEvent('ADDON_LOADED')
addon:SetScript('OnEvent', function(self, event, name)
    if(name ~= 'Blizzard_TimeManager') then return end

    TimeManager_UpdateTimeTicker = function()
        TimeManagerFrameTicker:SetText(date('%d/%m - %H:%M:%S'))
    end
end)
  Reply With Quote
08-21-10, 11:57 AM   #3
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
Nothing happens so far. What am I misunderstanding?

Code:
----------------------------------
-- Time
----------------------------------
if(not IsAddOnLoaded('Blizzard_TimeManager')) then
  LoadAddOn('Blizzard_TimeManager')
end

local clockFrame, clockTime = TimeManagerClockButton:GetRegions()
clockFrame:Hide()
clockTime:SetFontObject(SystemFont_Tiny)
    if(CalendarGetNumPendingInvites() > 0) then
		clockTime:SetTextColor(0, 1, 0)
	else
		clockTime:SetTextColor(1, 1, 1)
    end
TimeManagerClockButton:SetPoint("BOTTOM", Minimap, 0, 16)
TimeManagerClockButton:SetHeight(8)
TimeManagerClockButton:SetWidth(30)

local addon = CreateFrame('Frame')
addon:RegisterEvent('ADDON_LOADED')
addon:SetScript('OnEvent', function(self, event, name)
    if(name ~= 'Blizzard_TimeManager') then return end
        TimeManager_UpdateTimeTicker = function()
        TimeManagerFrameTicker:SetText(date('%d/%m - %H:%M:%S'))
    end
end)
__________________

  Reply With Quote
08-21-10, 12:20 PM   #4
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Well, you load the 'Blizzard_TimeManager at the beginning of your file, so there is no chance an ADDON_LOADED could fire for it after that code.

Either:
1. place your "addon"-part with the event-function before you call LoadAddOn()
2. remove the event-part and just hook the TimeManager_UpdateTimeTicker func
3. move all your code for the timeManager in the event-function and remove LoadAddOn(), so it gets called when the timeManager is loaded by Blizz.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-21-10, 12:33 PM   #5
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
I tried all your suggestion, still nothing happens.

Suggestion 3:
Code:
----------------------------------
-- Time
----------------------------------

local addon = CreateFrame('Frame')
addon:RegisterEvent('ADDON_LOADED')
addon:SetScript('OnEvent', function(self, event, name)
    if(name ~= 'Blizzard_TimeManager') then return end
        local clockFrame, clockTime = TimeManagerClockButton:GetRegions()
        clockFrame:Hide()
        clockTime:SetFontObject(SystemFont_Tiny)
            if(CalendarGetNumPendingInvites() > 0) then
                clockTime:SetTextColor(0, 1, 0)
            else
                clockTime:SetTextColor(1, 1, 1)
            end
        TimeManagerClockButton:SetPoint("BOTTOM", Minimap, 0, 16)
        TimeManagerClockButton:SetHeight(8)
        TimeManagerClockButton:SetWidth(30)
        TimeManager_UpdateTimeTicker = function()
        TimeManagerFrameTicker:SetText(date('%d/%m - %H:%M:%S'))
    end
end)
__________________

  Reply With Quote
08-21-10, 12:56 PM   #6
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
I don't know anything about the timeManager-frame, so I can't say if the code is working correctly, apart from syntax errors. (but I trust p3lim on that one )

Does the code in the event-function is called at all? Please check with a print() inside of it - or report whether your clock-modifications are working.
If not, maybe the timeManager-frame is already loaded, but then solution 2) should work.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hooking TimeManagerClockButton


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