Custom tooltip component

Source: Internet
Author: User
Tags cdata

The tooltip In Flex is a rectangle box with a text box. You can modify the style to set its size and background, font color, but cannot change its shape. If you want a tooltip such as a pentagram, You have to customize it. The following is a brief introduction to the custom tooltip method. The procedure is the same as that of other custom components. Because tooltip itself is a component, you only need to implement the itooltip interface

Create a component named mytooltip:

implements = "MX. core. itooltip "
width =" 500 "Height =" 100% "backgroundcolor =" # ffd7ff "borderstyle =" solid "cornerradius =" 5 ">

[Bindable]
private VaR _ text: string;
Public Function get text (): string
{< br> return this. _ text;
}< br>
public function set text (value: string): void
{< br> This. _ text = value;
}< br>]>


ThenProgramThe tooltip is used to listen to the tooltipcreate event in the component to display the tooltip. This event is called before the tooltip is created. Therefore, you can create a custom tooltip here, if you want to locate the position of the tooltip, you can listen to its tooltipshow event, which is called when you want to display the tooltip

<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" verticalalign = "Middle">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Events. tooltipevent;
Private function createmediltip (E: tooltipevent): void
{
VaR tip: mytooltip = new mytooltip ();
E. tooltip = tip;
}

// Tooltip positioning
Private function positiontooltip (E: tooltipevent): void
{
// Locate the tooltip at (5, 5) above the component.
// Var PT: Point = new point ();
// Pt. x = 0;
// Pt. Y = 0;
// Pt = BTN. localtoglobal (PT );
// E. tooltip. x = pt. x + 5;
// E. tooltip. Y = pt. Y-35;

// Position the tooltip below the current mouse (10, 20)
E. tooltip. x = mousex + 10;
E. tooltip. Y = Mousey + 20;
}
]>
</MX: SCRIPT>
<Mx: button id = "BTN" label = "testtooltip" tooltip = "test"
Tooltipcreate = "createconltip (event)" tooltipshow = "positiontooltip (event)"/>
</MX: Application>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.