Thread Tools Display Modes
09-20-05, 09:27 AM   #1
paulh
A Defias Bandit
Join Date: Sep 2005
Posts: 2
Launching a tooltip from an icon

Hi all,

I am trying to create a texture in a frame which when moused over will cause a tooltip to appear. It seems that the <Texture> element cannot have an <onEnter> event handler. I am assuming that I need to create a <Button> element and apply a texture to that, but I am struggling to find any documentation or examples about this.

In my XML file I have a button which inherits from one of the library buttons. I can get my icon to appear if I add the <Texture> element to the button, and also the <OnEnter> event handler works fine and the tool tip appears. But I have a big ugly button over the icon which obviously won't do.

Does anyone know of any examples I can look at. I have been using CT_RaidTracker but the addon is huge and complex and hurts my head

Thanks in advance.
  Reply With Quote
09-20-05, 10:09 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
You're correct textures can't have a Scripts section and you'll want a button that contains the texture. I assume you have the texture in the Layers section? Here's a "before" and "after" to move the texture to a button. It can be done in different ways:

Before:
Code:
<Frame name="MyModFrame" parent="UIParent">
	<Size>
		<AbsDimension x="200" y="200"/>
	</Size>
	<Anchors>
		<Anchor point="CENTER"/>
	</Anchors>
	<Layers>
		<Layer level="BACKGROUND">
			<Texture name="MyModTexture" file="Interface\Icons\INV_Misc_Coin_01">
				<Size>
					<AbsDimension x="32" y="32"/>
				</Size>
				<Anchors>
					<Anchor point="CENTER"/>
				</Anchors>
			</Texture>
		</Layer>
	</Layers>
</Frame>
After:
Code:
<Frame name="MyModFrame" parent="UIParent">
	<Size>
		<AbsDimension x="200" y="200"/>
	</Size>
	<Anchors>
		<Anchor point="CENTER"/>
	</Anchors>
	<Frames>
		<Button name="MyModButton">
			<Size>
				<AbsDimension x="32" y="32"/>
			</Size>
			<Anchors>
				<Anchor point="CENTER"/>
			</Anchors>
			<Layers>
				<Layer level="BACKGROUND">
					<Texture name="MyModTexture" file="Interface\Icons\INV_Misc_Coin_01">
						<Size>
							<AbsDimension x="32" y="32"/>
						</Size>
					</Texture>
				</Layer>
			</Layers>
			<Scripts>
				<OnEnter>
					GameTooltip:SetOwner(this,"ANCHOR_RIGHT")
					GameTooltip:AddLine("You entered MyModButton, which only contains MyModTexture")
					GameTooltip:Show()
				</OnEnter>
				<OnLeave>
					GameTooltip:Hide()
				</OnLeave>
			</Scripts>
		</Button>
	</Frames>
</Frame>
You'll note <Size> is defined both for the Button and the Texture. The OnEnter event is actually for the button itself, so we need the button to cover the 32x32 to receive the OnEnter. The texture can be 64x64 on disk, but I don't believe it limits itself to the size of its parent. (Could be wrong on this). So a 32x32 size is defined for the texture too. Alternately, instead of a <Size> within the Texture, you can set two anchors:
Code:
<Texture name="MyModTexture" file="Interface\Icons\INV_Misc_Coin_01">
	<Anchors>
		<Anchor point="TOPLEFT" relativeTo="MyModButton" relativePoint="TOPLEFT"/>
		<Anchor point="BOTTOMRIGHT" relativeTo="MyModButton" relativePoint="BOTTOMRIGHT"/>
	</Anchors>
</Texture>
This will stretch the texture to cover the entire Button. So you only have to worry about the Button's size.

Every last tag isn't needed and some shortcuts can be made (ie, relativeTo can be dropped I'm pretty sure) if you run across other examples.

Last edited by Gello : 09-20-05 at 10:11 AM.
  Reply With Quote
09-20-05, 10:48 AM   #3
paulh
A Defias Bandit
Join Date: Sep 2005
Posts: 2
Thanks alot, worked like a charm
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Launching a tooltip from an icon

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off