Charibot@legacy41530750 (talk | contribs) m (catfix, Replaced: {{widgethandler}} → {{widgethandler}}<br>) |
No edit summary Tag: WoW API docs |
||
(21 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | {{widgethandler}} |
+ | {{widgethandler|notitle=}} |
+ | Invoked when the cursor enters the widget's interactive area. |
||
+ | [[UIOBJECT ScriptRegion|ScriptRegion]] OnEnter(self, motion) |
||
− | == |
+ | ==Arguments== |
+ | :;self:{{apitype|ScriptObject}} - The widget the cursor is hovering over. |
||
+ | :;motion:{{apitype|boolean}} - True if the handler is being run due to actual mouse movement; false if the cursor entered the frame due to other circumstances (such as the frame being created underneath the cursor) |
||
⚫ | |||
− | The OnEnter handler is called when the user mouse pointer enters the frame. |
||
+ | <syntaxhighlight lang="lua"> |
||
+ | local f = CreateFrame("Frame", nil, nil, "BackdropTemplate") |
||
+ | f:SetPoint("CENTER") |
||
+ | f:SetSize(100, 100) |
||
+ | f:SetBackdrop(BACKDROP_TUTORIAL_16_16) |
||
+ | f:SetScript("OnEnter", function(self, motion) |
||
− | A typical use for this event is to pop up a help tooltip, or a menu with option choices (for instance on a minimap button). The opposite of OnEnter is [[UIHANDLER OnLeave|OnLeave]]. If you decide to show something in OnEnter you should hide it again in the [[UIHANDLER OnLeave|OnLeave]] event handler. |
||
+ | GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") |
||
− | |||
+ | GameTooltip:SetText("Hello World") |
||
− | == Arguments == |
||
⚫ | |||
− | |||
+ | f:SetScript("OnLeave", function(self, motion) |
||
− | No known arguments |
||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
+ | </syntaxhighlight> |
||
− | This example illustrates how to use OnEnter and [[UIHANDLER OnLeave|OnLeave]] to display a mouseover help text in the GameTooltip. |
||
+ | [[File:UIHANDLER_OnEnter_01.mp4|300px]] |
||
− | |||
− | Declare the event handlers in the "Scripts" section of your frame: |
||
− | |||
− | <Frame name="MyFrame"> |
||
− | <Scripts> |
||
− | <OnEnter> MyFrame_OnEnter() </OnEnter> |
||
− | <OnLeave> MyFrame_OnLeave() </OnLeave> |
||
− | </Scripts> |
||
− | </Frame> |
||
− | |||
− | Place the actual functions in one of your LUA files: |
||
− | |||
− | function MyFrame_OnEnter() |
||
− | GameTooltip_SetDefaultAnchor( GameTooltip, UIParent ) |
||
− | GameTooltip:SetText( "This text shows up when you mouse over\nthe MyFrame frame" ) |
||
− | GameTooltip:Show() |
||
⚫ | |||
− | |||
− | function MyFrame_OnLeave() |
||
⚫ | |||
⚫ |
Latest revision as of 09:27, 18 August 2023
The API is no longer being updated here until further notice. |
Invoked when the cursor enters the widget's interactive area.
ScriptRegion OnEnter(self, motion)
Arguments
- self
- ScriptObject - The widget the cursor is hovering over.
- motion
- boolean - True if the handler is being run due to actual mouse movement; false if the cursor entered the frame due to other circumstances (such as the frame being created underneath the cursor)
Example
local f = CreateFrame("Frame", nil, nil, "BackdropTemplate")
f:SetPoint("CENTER")
f:SetSize(100, 100)
f:SetBackdrop(BACKDROP_TUTORIAL_16_16)
f:SetScript("OnEnter", function(self, motion)
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
GameTooltip:SetText("Hello World")
end)
f:SetScript("OnLeave", function(self, motion)
GameTooltip:Hide()
end)