GetMouseFocus replaced by GetMouseFoci #21


  • Defect
Closed
Assigned to arithmandar
  • xam_insight created this issue Jul 5, 2024

    Hello!

     

    As documented here, the GetMouseFocus will be replaced by GetMouseFoci in TWW but it works a little different.

    On TWW test servers, the usage of GetMouseFocus causes null errors.

     

    Here is the fix found by Kharthus on the addon ItemRack.

     

    if tocversion >= 110000 then
    	local region = GetMouseFoci()
    	local frame = region[1]
    else
    	local frame = GetMouseFocus()
    end

     

    Regards :)

  • xam_insight added a tag Defect Jul 5, 2024
  • xam_insight posted a comment Jul 5, 2024

    I suggest this fix on line 118 of LibUIDropDownMenu.lua but I cannot test it as the test servers are down at the moment.

     

     

    function lib:UIDropDownMenuButton_ShouldShowIconTooltip(self)
    	if self.Icon and (self.iconTooltipTitle or self.iconTooltipText) and (self.icon or self.mouseOverIcon) then
    		if wowversion >= 110000 then
    			local region = GetMouseFoci()
    			local frame = region[1]
    		else
    			local frame = GetMouseFocus()
    		end
    		return frame == self.Icon;
    	end
    	return false;
    end

     


    Edited Jul 13, 2024
  • xam_insight posted a comment Jul 12, 2024

    PTR still not open in my region. Unable to test the fix :/

  • xam_insight posted a comment Jul 13, 2024

    Servers are up.

    I replace tocversion by wowversion above ;)


    Edited Jul 13, 2024
  • xam_insight posted a comment Dec 13, 2024

    Now that Classic also use GetMouseFoci, I changed the code to:

     

    function lib:UIDropDownMenuButton_ShouldShowIconTooltip(self)
    	if self.Icon and (self.iconTooltipTitle or self.iconTooltipText) and (self.icon or self.mouseOverIcon) then
    		if GetMouseFoci then
    			local region = GetMouseFoci()
    			local frame = region[1]
    		else
    			local frame = GetMouseFocus()
    		end
    		return frame == self.Icon;
    	end
    	return false;
    end

     


    Edited Dec 13, 2024
  • arithmandar closed issue Sep 28, 2026
  • arithmandar posted a comment Sep 28, 2026

    Sorry for my super-late response.
    I was away for quite a while.

    Looking at this issue again, I guess it's no longer a concern.
    GetMouseFoci now supports in all game client, but also, as instructed in API page here: https://warcraft.wiki.gg/wiki/API:GetMouseFoci

    For the common case of simply testing if a region has mouse focus, consider using ScriptRegion:IsMouseMotionFocus().

    And the current release has migrated to use codes like below:

     

    function lib:UIDropDownMenuButton_ShouldShowIconTooltip(self)
    	if self.Icon and (self.iconTooltipTitle or self.iconTooltipText) and (self.icon or self.mouseOverIcon) then
    		return self.Icon:IsMouseMotionFocus();
    	end
    	return false;
    end

     

     

    Thanks again for trying to reach out to me and drawing for my attention.


    Edited Sep 28, 2026
  • arithmandar self-assigned this issue Sep 28, 2026

To post a comment, please login or register a new account.