I would like to bring attention to a minor issue. Some plugins seem to not be fully implementing their OnLeave handlers, specifically the second argument, motion, that it is passed. That argument evaluates as true if the OnLeave handler was called due to mouse movement, otherwise it means the frame lost focus for some other reason.
When a plugin is being dragged the motion arg will evaluate as false. This should result in any attached drop-down menu or tooltip being removed immediately. Ignoring that second arg results in plugins being dragged and still having their tooltip (or a menu) attached when it shouldn't.
Also, do NOT modify the frame that is passed as the first argument with OnEnter/OnLeave. You have no idea which display will be hosting your plugin and therefore don't know which fields are safe to modify.
dataObj.OnEnter = function(self, motion)
self.tooltip = GameTooltip
< snip >
end
dataObj.OnLeave = function(self, motion)
if self.tooltip then
self.tooltip:Hide()
self.tooltip = nil
end
end
The 'self' in those functions does not end up being dataObj, so stop playing with your 'self'. :)
I'm still pretty new to all of this, but shouldn't the display add-on be handling the hiding and resetting of the tool tips when the object is dragged? I know Docking Station does it. /shrug
Edit: Also, having a dewdrop drop-down hide on-leave just doesn't work if you're only displaying the icon. :/
If the display wants tips hidden while dragging, it should call the onleave when drag starts, and onenter when it ends. And yes, the DO shouldn't be changing that "self" really. Either way, it's something you should address to the specific authors who are doing things wrong, a general forum thread here is not likely to get their attention.
Well, I'm actually using the OnTooltipShow() rather than OnEnter/OnLeave. As far as hiding the Dewdrop menu, not sure how I can do that without causing it to hide prematurely when it's not being dragged. :/
Ah. So is there anyway to hook into the object's OnDragStart or anything so I can my menu?
If you are anchoring anything to a plugin then you would be much better off switching to using OnEnter/OnLeave just so you have an easy way to know when to hide it.
That still doesn't solve the problem of premature hiding because the menu is offset enough that the mouse moves off the object before it hits the menu. Honestly, the menu hiding doesn't seem worth the trouble of fooling the OnEnter stuff, which I've no clue about. :p
I was thinking more along the lines of (rough outline):
local menuShowing = false
local function OnClick(self, button)
if button == 'LeftButton' then
-- Do stuff
elseif button == 'RightButton' then
-- Hide tooltip
-- Show drop-down menu
menuShowing = true
end
end
local function OnEnter(self, motion)
if menuShowing then
-- Stop timer for hiding the drop-down menu
else
-- Show tooltip
end
end
local function OnLeave(self, motion)
if menuShowing then
if motion then
-- Start timer to hide the drop-down menu
else
-- Hide drop-down menu
menuShowing = false
end
else
-- Hide tooltip
end
end
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
When a plugin is being dragged the motion arg will evaluate as false. This should result in any attached drop-down menu or tooltip being removed immediately. Ignoring that second arg results in plugins being dragged and still having their tooltip (or a menu) attached when it shouldn't.
Also, do NOT modify the frame that is passed as the first argument with OnEnter/OnLeave. You have no idea which display will be hosting your plugin and therefore don't know which fields are safe to modify.
The 'self' in those functions does not end up being dataObj, so stop playing with your 'self'. :)
Edit: Also, having a dewdrop drop-down hide on-leave just doesn't work if you're only displaying the icon. :/