HizurosWoWAddOns / FarmHud

Turn your minimap into a hud for farming ore / herb.
GNU General Public License v3.0
5 stars 7 forks source link

[BUG]: FarmHud enables mouse input/events on child frames when hooking scripts #10

Open ls- opened 1 year ago

ls- commented 1 year ago

WoW client

WoW Retail

What happened?

And why is it a problem? If there's a frame from another addon that houses an overlay for the minimap or whatever, it'll prevent users from pinging, seeing minimap tooltips, and clicking on the minimap.

The issue originates in this block. but because I'm not particularly familiar with the addon's code/functionality, I chose not to PR it and instead create a ticket.

But overall there's two solutions, either reset the mouse state after you hooked everything

local objMT = getmetatable(obj).__index;
+local mouse = objMT .IsMouseEnabled(obj);
objMT .HookScript(obj,"OnEnter",objHookStart);
objMT .HookScript(obj,"OnDragStart",objHookStart);
objMT .HookScript(obj,"OnLeave",objHookStop);
objMT .HookScript(obj,"OnDragStop",objHookStop);
+objMT .EnableMouse(obj, mouse);

or only hook things if mouse input is enabled in the first place

local objMT = getmetatable(obj).__index;
+if objMT .IsMouseEnabled(obj) then
    objMT .HookScript(obj,"OnEnter",objHookStart);
    objMT .HookScript(obj,"OnDragStart",objHookStart);
    objMT .HookScript(obj,"OnLeave",objHookStop);
    objMT .HookScript(obj,"OnDragStop",objHookStop);
+end

I tried to follow your style 😝

Lua Error Message?

No response

Other addons?

No response

ls- commented 1 year ago

Btw, I believe this is also the cause of #2.

Sinaloit commented 8 months ago

This does seem to resolve #2 as well.