`
石头茨
  • 浏览: 18827 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

Using htmlText in a toolTip in flex

    博客分类:
  • flex
阅读更多
转载:http://www.axelscript.com/2008/02/29/using-htmltext-in-a-tooltip-in-flex/

My previous post was on using the dataTip in flex… the link is here:

CLICK HERE TO GO TO PREVIOUS POST

I’m talk briefly from time to time with Maikel Sibbald from holland, and I used his post on using tooltips and the customization of them… ( I loved the post Mike! ) Someone commented on my post about using dataTips in flex (link at top of this post)… the dataTip term comes from the attribute you give to the datagrid… “showDataTips” but it is in all reality a “ToolTip”. I just wnated to clear that up…

The second thing is, I wanted to kind of walk through how to accomplish the custom tool tip, and how to apply css, and use htmlText in your custom ToolTip.

First off, hopefully you know this, and are familiar with css in flex… it’s not quite html css, it’s compiled into the .swf file… and the the syntax is although similar, not quite the same…

First you have your style tag, and your css.

<mx:Style>
ToolTip{
font-family: arial;
font-size: 12px;
color: #000000;
background-color: #FFFFFF;
background-alpha: 0.85;
borderSkin: ClassReference(“MyToolTip”);
}
</mx:Style>


You will notice the odd attribute/value pair called “borderSkin:” the value of this maybe unlike anything you’ve ever seen in html css… thats because it is… You give this value the ClassReference(“MyToolTip”); which relates to a “MyToolTip.as” Class that I have in my Example, but this could very well be a “MyToolTip.mxml”…

You then want to create your custom Class, and you want to Extend your ToolTipBorder Class. You might originally think to extend the ToolTip Class, but that wouldn’t comply with the css tactics we are using here.

The next thing your going to want to do, is create a function that override’s the super()’s function updateDisplayList…

Within that class, your going to declare your toolTip from your parent…

var toolTip:ToolTip = (this.parent as ToolTip);

The ToolTip Class creates something called a textField that is a UITextField… I found this by rummaging through the original ToolTip Class… (not hard to find, just write something like and hold ctrl on the keyboard and click on the class… it should jump to the original documented class.
You are going to override this in the new function, and this is whats going to make the html text actually work.

var textField:UITextField = toolTip.getChildAt(1) as UITextField;

textField.htmlText = textField.text;

As you can see in the code, that Maikel creates this text field and goes from there calculating some padding for the htmlText.

var calHeight:Number = textField.height;
calHeight += textField.y*2;
calHeight += textField.getStyle(“paddingTop”);
calHeight += textField.getStyle(“paddingBottom”);

var calWidth:Number = textField.textWidth;
calWidth += textField.x*2;
calWidth += textField.getStyle(“paddingLeft”);
calWidth += textField.getStyle(“paddingRight”);

super.updateDisplayList(calWidth, calHeight);

Then last but not least your going to call your super.updateDisplayList method, and that will update and redraw your display.

As for where I come in… I was asked in my other post, on if you could put an image into the toolTip in flex… and the answer is ABSOLUTELY.

here is the html toolTip with the html Image, i’m working on making this more elegant, and creating a custom tool tip that accepts an image, but just am running short on time lately… I will return!

but if you hover over the button in the following link, you will see an html image show up in the tool tip, like i said this is not an elegant way of doing this, because you will have to statically set the width and height of your tooltip… if your okay with doing that, then this is a fine situation to do so… check it out

APPLICATION – SOURCE

分享到:
评论

相关推荐

    flex tooltip

    标题中的“flex tooltip”指的是Adobe Flex中的一种交互设计元素,Tooltip。在Flex应用程序开发中,Tooltip是用来显示鼠标悬停在某个组件上时提供额外信息的小型弹出窗口。它可以帮助用户理解控件的功能或者显示一些...

    Flex 自定义ToolTip

    ### Flex自定义ToolTip详解 在Flex开发中,`ToolTip`是一种非常实用的界面元素,用于在用户悬停或聚焦某个控件时显示额外的信息。默认情况下,Flex提供了基本的`ToolTip`功能,但有时为了满足特定的设计需求或者...

    flex ToolTip汇总

    本文将深入探讨“flex ToolTip”的概念、使用方法和常见应用,这在网页和桌面应用的交互设计中起着重要作用。 `ToolTip`是用户界面中的一个关键元素,它提供了一种在鼠标悬停时显示额外信息的方式。在flex中,`...

    Using Edit box as static Text Control for displaying ToolTip

    这个"Using Edit box as static Text Control for displaying ToolTip"的主题就是关于如何巧妙地结合这两者,以实现更灵活的界面设计。 首先,我们要理解Edit控件和Static控件的基本特性。Edit控件通常用于让用户...

    WXA-ToolTip-微信小程序-ToolTip信息提示组件.zip

    微信小程序-ToolTip信息提示组件导入将ToolTip文件夹复制到pages文件夹内使用在需要使用ToolTip的页面对应的.wxml文件中添加: src="../ToolTip/toolTip.wxml"/&gt; &lt;!-- 引入toolTip模板 --&gt;  is=...

    Label的ToolTip属性,或是a标签的提示换行问题

    在探讨“Label的ToolTip属性,或是a标签的提示换行问题”这一主题时,我们首先需要理解几个核心概念:ToolTip属性、HTML编码与解码、以及如何在网页中实现文本的换行。以下是对这些概念的详细解析: ### 1. ToolTip...

    表格单元格自定义ToolTip组件

    这种自定义的ToolTip在Flex组件上特别有用,Flex是一种强大的富互联网应用程序(RIA)开发框架,由Adobe提供。 ToolTip通常是在鼠标悬停在某个元素上时显示的一小段文本,用于提供额外的上下文信息。在标准的DataGrid...

    提示框程序Balloon ToolTip Control

    how to combine the good of both, in a way that's as simple as using the native .NET ToolTip control. While searching around, I found a great article about the Balloon ToolTip control (actually about...

    Tooltip

    【Tooltip】是一个在软件开发中常见的用户界面元素,它的全称是“工具提示”,用于向用户提供额外的信息。当用户将鼠标悬停在某个控件上时,Tooltip会显示一个小窗口,展示该控件的功能或者相关说明,帮助用户理解不...

    HTML5鼠标悬停弹性动画Tooltip提示框特效

    text-align: center; padding: 5px; border-radius: 6px; position: absolute; z-index: 1; bottom: 100%; left: 50%; margin-left: -60px; /* half of tooltip width */ opacity: 0; transition: ...

    tooltip

    这个压缩包文件包含了一些关于tooltip实现的基本资源,如样式表(tooltip.css),HTML页面(tooltip.htm),以及可能的JavaScript脚本(tooltip.js)用于交互逻辑。这些文件对于初学者来说是很好的学习材料,可以...

    HTML5 SVG弹性Tooltip提示框特效.zip

    总结来说,"HTML5 SVG弹性Tooltip提示框特效"是HTML5和SVG技术与Anime.js动画库的完美融合,展示了现代Web开发中的创新和可能性。通过学习和应用这些技术,开发者可以创造出更富有表现力和吸引力的网页应用程序,...

    flash 的几个tooltip显示

    - AS3(ActionScript 3.0):引入`flash.ui.ToolTip`类,创建一个Tooltip实例并用`new ToolTip()`初始化,然后使用`ToolTip.displayObject.text`设置文本。 3. 自定义Tooltip样式: - 通过修改Tooltip的样式属性...

    ExtJS ToolTip功能

    ### ExtJS ToolTip功能 #### 知识点详解 在ExtJS中,`ToolTip`功能是一种非常实用且灵活的功能,它允许用户在鼠标悬停在某个元素上时显示额外的信息。这种特性对于提高用户界面的可用性和用户体验尤其有用。本文将...

    对超长HTML控件内容展现ToolTip信息控件代码

    2. **文本裁剪**:一旦发现内容过长,我们可以使用CSS的`text-overflow`属性来裁剪超出的部分,并设置`white-space`属性为`nowrap`以防止换行。同时,可以使用`overflow`属性隐藏超出的文本。 3. **创建ToolTip**:...

    ToolTip提示脚本文件

    【ToolTip提示脚本文件】 在IT领域,ToolTip是一种常见的用户界面元素,用于向用户提供额外的信息。当鼠标指针悬停在某个元素上时,ToolTip会显示一个包含详细说明的小窗口,帮助用户理解该元素的功能或内容。在...

    WPF修改Tooltip样式

    在Windows Presentation Foundation (WPF) 中,Tooltip是一个用于显示与鼠标指针相关的简短提示信息的控件。它通常在用户将鼠标悬停在其他UI元素上时出现,提供额外的信息。在默认情况下,Tooltip的样式是有限的,但...

    vc中tooltip应用

    在VC++编程环境中,Tooltip是一种常见的用户界面组件,它能够在鼠标悬停在某个控件上时,显示简短的信息提示。"vc中tooltip应用"这个主题着重于如何在Visual C++项目中有效地利用Tooltip控件,提升用户体验。下面将...

Global site tag (gtag.js) - Google Analytics