Search code examples
apache-flexactionscriptmxmlflex-spark

How can I only show ToolTip on specific words in a Label?


Take this text for example.

I would like to be able to display something like the text above, and let the user mouse over "text" and "example" to get two different ToolTip messages (lets say, "text: noun...definition: ...", and "example: noun...definition" respectively).

In this case, the text is static, so one option would be to put 4 different labels next to each other and style them differently. This might work in most cases, but i also need the text to word-wrap which wouldn't work with individual labels.

Can anyone recommend a solution for this?


Solution

  • It doesn't seem to get much love in our community, but you'll want to look at the TLF Engine. Specifically a TextFlow which has said "primitive" events (eg mouse__, roll__) for links. Style the link appropriately, and in theory you should be close to being done. Since this isn't a Flex-SDK baked-in component, it won't handle the toolTip for you, but it's easy enough to replicate. Create a new ToolTip manually - and add it to the PopUpManager.

    http://help.adobe.com/en_US/flex/using/WS02f7d8d4857b1677-165a04e1126951a2d98-7ffc.html