WoW:UIHANDLER OnEnter: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
(improved the description and added an example)
Line 1: Line 1:
{{Stub/API}}
{{widgethandler}}
{{widgethandler}}


Line 5: Line 4:


The OnEnter handler is called when the user mouse pointer enters the frame.
The OnEnter handler is called when the user mouse pointer enters the frame.
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.


== Arguments ==
== Arguments ==


Unknown
No known arguments
 
== Example ==
This example illustrates how to use OnEnter and [[UIHANDLER OnLeave|OnLeave]] to display a mouseover help text in the GameTooltip.
 
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()
end
function MyFrame_OnLeave()
  GameTooltip:Hide()
end

Revision as of 18:43, 1 October 2007

Widget handlers < OnEnter

Description

The OnEnter handler is called when the user mouse pointer enters the frame.

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 OnLeave. If you decide to show something in OnEnter you should hide it again in the OnLeave event handler.

Arguments

No known arguments

Example

This example illustrates how to use OnEnter and OnLeave to display a mouseover help text in the GameTooltip.

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()
end

function MyFrame_OnLeave()
  GameTooltip:Hide()
end