Thread Tools Display Modes
02-13-12, 03:08 PM   #1
Xpload
A Defias Bandit
 
Xpload's Avatar
Join Date: Jan 2011
Posts: 3
Highlight selected unit

Any ideas how to do so?
  Reply With Quote
02-13-12, 07:42 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Depends on what you mean by "selected unit".

If you want to highlight the frame the mouse is currently over, the simplest solution is to simply add a highlight texture to the frame:

Code:
self:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
If you want to have more control over what happens (such as changing the color of the health bar) instead of showing/hiding a simple full-sized texture, you can handle that in the frame's OnEnter and OnLeave scripts:

Code:
self:HookScript("OnEnter", function(self)
    -- do stuff here when the mouse moves over the frame
end)

self:HookScript("OnLeave", function(self)
    -- do stuff here when the mouse moves off the frame
end)
If you want to highlight the frame whose unit you are currently targeting, you would need to register the PLAYER_TARGET_CHANGED event on your frame:

Code:
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self.PLAYER_TARGET_CHANGED = function(self)
    if UnitExists("target") and UnitIsUnit(self.unit, "target") then
        -- you are currently targeting this frame's unit
    else
        -- you are not targeting this frame's unit
    end
end
  Reply With Quote
02-14-12, 02:36 AM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Phanx View Post
Depends on what you mean by "selected unit".

If you want to highlight the frame the mouse is currently over, the simplest solution is to simply add a highlight texture to the frame:

Code:
self:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
Nice actually been looking for this for!

It works, but it has an lower layer so you can't actually see it

Was really missing this feature from Grid

Just made my own alot easier

LUA Code:
  1. local InvisFrame = CreateFrame("Frame", nil, self)
  2.     InvisFrame:SetFrameStrata("MEDIUM")
  3.     InvisFrame:SetFrameLevel(5)
  4.     InvisFrame:SetAllPoints()
  5.  
  6.     local Background = InvisFrame:CreateTexture(nil, 'BORDER')
  7.     Background:SetTexture("Interface\\Buttons\\WHITE8x8") -- or "Interface\\QuestFrame\\UI-QuestTitleHighlight"
  8.     Background:SetAllPoints()
  9.     Background:SetAlpha(0) -- make sure it doesn't show untill we actually enter the frame.
  10.    
  11.     self:HookScript("OnEnter", function(self)
  12.         Background:SetVertexColor(1, 0.82, 0, 0.2)
  13.     end)
  14.  
  15.     self:HookScript("OnLeave", function(self)
  16.         Background:SetVertexColor(0, 0, 0, 0)
  17.     end)

Last edited by Aftermathhqt : 02-14-12 at 10:26 AM.
  Reply With Quote
02-14-12, 05:02 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can also modify the highlight texture, to raise it, etc:

local textureObject = frame:GetHighlightTexture()
  Reply With Quote
02-14-12, 07:09 PM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Phanx View Post
You can also modify the highlight texture, to raise it, etc:

local textureObject = frame:GetHighlightTexture()
Hmm okey^^ well i'm sorted anyways. Thanks for help through.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Highlight selected unit


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