Quantcast
Download
(1 Kb)
Download
Updated: 03-02-18 10:15 PM
Pictures
File Info
Compatibility:
Shadows of Argus (7.3.0)
Updated:03-02-18 10:15 PM
Created:03-02-18 10:15 PM
Downloads:181
Favorites:1
MD5:
7.3.0

Anchor Tooltip to Mouse

Version: 1.0
by: Ammako [More]

This changes the anchor point of world object tooltips to the cursor, following the mouse cursor around. Interface tooltips keep their default position.

Also makes tooltips disappear instantly when you mouse away rather than slowly fading away.


Includes a quick fix to the background color of tooltips sometimes screwing up a little bit (not sure how relevant this is nowadays, but it doesn't appear break anything so I'm leaving it in.)


Note: I couldn't get this to work properly when trying to make the tooltip anchor to the bottom-right, so it sits with the cursor being at the bottom-middle of the tooltip. If you can get this to work properly, I'm all ears.

Post A Reply Comment Options
Unread 06-09-18, 03:52 PM  
Ammako
A Cobalt Mageweaver
 
Ammako's Avatar
AddOn Author - Click to view AddOns

Forum posts: 208
File comments: 13
Uploads: 6
I noticed strange behavior on world object tooltips where the tooltip appears at bottom-middle before immediately anchoring back over to bottom-right, I can fix that by also running that function OnShow once before letting OnUpdate take over.

lua Code:
  1. GameTooltip:HookScript("OnUpdate", function() GameTooltip:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, 1) end)
  2. hooksecurefunc(GameTooltip, "FadeOut", function(self) self:Hide() end)
  3.  
  4. local function AnchorFrameToMouse(frame)
  5.     local x, y = GetCursorPosition()
  6.     local effScale = frame:GetEffectiveScale()
  7.     frame:ClearAllPoints()
  8.     frame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMLEFT", (x / effScale), (y / effScale))
  9. end
  10.  
  11. hooksecurefunc("GameTooltip_SetDefaultAnchor", function(tooltip, parent)
  12.     if GetMouseFocus() ~= WorldFrame then return end
  13.     tooltip:SetOwner(parent, "ANCHOR_CURSOR")
  14.     AnchorFrameToMouse(tooltip)
  15.     tooltip.default = 1
  16. end)
  17.  
  18. GameTooltip:HookScript("OnShow", function(self, elapsed)
  19.     if GetMouseFocus() ~= WorldFrame then return end
  20.     AnchorFrameToMouse(self)
  21. end)
  22.  
  23. GameTooltip:HookScript("OnUpdate", function(self, elapsed)
  24.     if GetMouseFocus() ~= WorldFrame then return end
  25.     AnchorFrameToMouse(self)
  26. end)
__________________
█████████████
█████████████
█████████████
█████████████
Report comment to moderator  
Reply With Quote
Unread 06-09-18, 02:07 AM  
Ammako
A Cobalt Mageweaver
 
Ammako's Avatar
AddOn Author - Click to view AddOns

Forum posts: 208
File comments: 13
Uploads: 6
I really hate this, but it works:

lua Code:
  1. GameTooltip:HookScript("OnUpdate", function() GameTooltip:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, 1) end)
  2. hooksecurefunc(GameTooltip, "FadeOut", function(self) self:Hide() end)
  3.  
  4. local function AnchorFrameToMouse(frame)
  5.     local x, y = GetCursorPosition()
  6.     local effScale = frame:GetEffectiveScale()
  7.     frame:ClearAllPoints()
  8.     frame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMLEFT", (x / effScale), (y / effScale))
  9. end
  10.  
  11. hooksecurefunc("GameTooltip_SetDefaultAnchor", function(tooltip, parent)
  12.     if GetMouseFocus() ~= WorldFrame then return end
  13.     tooltip:SetOwner(parent, "ANCHOR_CURSOR")
  14.     AnchorFrameToMouse(tooltip)
  15.     tooltip.default = 1
  16. end)
  17.  
  18. GameTooltip:HookScript("OnUpdate", function(self, elapsed)
  19.     if GetMouseFocus() ~= WorldFrame then return end
  20.     AnchorFrameToMouse(self)
  21. end)

For whatever reason it refuses to properly update X coordinate when anchoring at the bottom corners unless I force update it every frame, when it has absolutely no problems doing it when anchoring at the bottom.

Need to set the anchor once during GameTooltip_SetDefaultAnchor to avoid weird graphical issues, and then a hook keeps the same function running over and over again afterwards. I'm probably not going to release this as an update yet because OnUpdate is bad and there has to be a better solution, but if anybody wants this badly enough, the code is here.
__________________
█████████████
█████████████
█████████████
█████████████
Report comment to moderator  
Reply With Quote
Unread 06-09-18, 01:24 AM  
Theroxis
A Murloc Raider

Forum posts: 4
File comments: 1
Uploads: 0
Bottom Right Anchor

To achieve this is quite simple:
Code:
GameTooltip:HookScript("OnUpdate", function(self, elpased)
		local x, y = GetCursorPosition()
		local effScale = self:GetEffectiveScale()
		self:ClearAllPoints()
		self:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", (x / effScale + 25), (y / effScale + -25))
This idea is completely stolen from the old addon "lolTip"


Anyways, basically you HookScript the "OnUpdate" function of the tooltip; since this is called every time the mouse moves on something that produces a tooltip, it mimics the same behavior as setting the anchor to the mouse. Then we grab the X and Y position of the cursor using the builtin, as well as the effective scale of the tooltip. This way the code works even if someone uses the UiScale to change the size of the UI. Finally we do some cheeky math to set the position of the tooltip frame to 25 pixels to the right, and 25 pixels below the cursor. There is some odd behavior in my edit to this I'm trying to figure out, but I'm trying to do slightly more complicated things.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: