This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
Tooltip Offset
Post Reply
Return to board index
Post by
123476
This post was from a user who has deleted their account.
Post by
MeanMachine
Well that's fairly easy. You probably overlooked the fact that SetOwner can take two additional arguments - x and y offset.
Post by
123476
This post was from a user who has deleted their account.
Post by
Wanderingfox
Anchor it to UIParent and offset by the screen dimensions?
something like this (Warning pseudo code):
local cursorX, cursorY = GetCursorPosition()
local offsetX = 0
local offsetY = 0
GameTooltip:SetOwner(CurrentCursorAnchor, UIParent, cursorX + offsetX, cursorY + offsetY)
edit:
Though doing something like that can put the tooltip off the screen, but that can be resolved with some more math and dealing with offsets.
If you want some real code to look at, I believe Cowtip (
http://files.wowace.com/CowTip/
) has some nice clean code for doing it (check in the position.lua file).
Post by
91244
This post was from a user who has deleted their account.
Post by
Wanderingfox
I'm really not sure there is an elegant solution, almost every addon I've seen that deals with custom tooltip positioning has it anchored either off UIParent, or some other static frame (which would yield the same results).
edit:
Come to think of it... is there a reason you can't offset from the cursor anchor? I can't think of any >_<
Post by
123476
This post was from a user who has deleted their account.
Post by
MeanMachine
Well you could try to "emulate" the mouse anchoring by setting the tooltip's position every time the cursor moves. It's basically the way it works anyway. Though nefarion's work-around doesn't work? I guess the tooltip doesn't depend so much on the owner frame rather than the anchor.
Post by
91244
This post was from a user who has deleted their account.
Post by
Wanderingfox
This is how cowtip does it, so it obviously does work >_>
local function ReanchorTooltip()
GameTooltip:ClearAllPoints()
local scale = GameTooltip:GetEffectiveScale()
if currentAnchorType == "PARENT" then
GameTooltip:SetPoint(currentCursorAnchor, currentOwner, anchorOpposite, currentOffsetX, currentOffsetY)
else -- CURSOR
local x, y = GetCursorPosition()
x, y = x / scale + currentOffsetX, y / scale + currentOffsetY
GameTooltip:SetPoint(currentCursorAnchor, UIParent, "BOTTOMLEFT", x, y)
end
end
Credit to ckknight et all
Post by
MeanMachine
Well, looks basically like what I suggested. It'll still have to be constantly "reanchored". Anyway, call it ugly but it's basically how it works. At some point you just have to update every time the cursor moves. Personally I don't mind doing it in the addon code, but then again I don't program addons much.
Oh, and for the love of god don't update it 1000 times per second. Set some manageable baseline.
Oh and yeah, won't hurt to suggest cursor offsets on the wow forums.
Post by
123476
This post was from a user who has deleted their account.
Post by
91244
This post was from a user who has deleted their account.
Post by
Wanderingfox
You don't even need to update it every on update either, updating it every x onupdates should be enough (I think cowtip uses something like every 6).
Post by
91244
This post was from a user who has deleted their account.
Post by
Wanderingfox
Oh I know, I was just pointing out that if he's that worried about it causing an issue it could be throttled further XD
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.