Warning: Creating default object from empty value in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-includes/functions.php on line 292
Joeflash’s Enigmacopaedia » Simple Monkeypatch to fix ToolTipManager.destroyToolTip RTE

Joeflash’s Enigmacopaedia


Simple Monkeypatch to fix ToolTipManager.destroyToolTip RTE

Posted in Flex, Flex 3 by Joeflash on the March 13th, 2010

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/codecolorer.php on line 161

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/lib/geshi.php on line 2148

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-content/plugins/codecolorer/codecolorer.php on line 162

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h02/mnt/36638/domains/joeflash.ca/html/blog/wp-includes/functions-formatting.php on line 76

So I’m coding a custom tooltip which stays visible when you click on the target (more on that in a future post), so I need to manage the tooltip behaviour with ToolTipManager.createToolTip rather than the UIComponent’s tooltip property, or tooltip events. Ben Clinkinbeard’s monkey patch for ToolTipManagerImpl came in real handy for this.

From this “always on” tooltip, I have a button which asks the user for confirmation before performing the action, after which I dismiss the tooltip. Problem is, an RTE “The supplied DisplayObject must be a child of the caller” always ensues.

Until I realized that calling Alert.show() when a tooltip is showing always dismisses the currentToolTip. So calling ToolTipManager.destroyToolTip on a ToolTip which had already been “dismissed” would of course generate an RTE.

Shouldn’t the ToolTipManagerImpl class be smart enough to figure this out without bugging me with an RTE? Shouldn’t it check first to see if there are children present to remove before attempting to remove them? There may be other situations in my app where I may not always be aware of whether my tooltip is located in the toolTipChildren list.

So, taking a cue from Ben’s monkeypatch, I scrolled down to the next function, and monkeypatched mx.managers.ToolTipManagerImpl.destroyToolTip():

Original code:

  1. public function destroyToolTip(toolTip:IToolTip):void
  2. {
  3.     var sm:ISystemManager = toolTip.systemManager as ISystemManager;
  4.     sm.topLevelSystemManager.removeChildFromSandboxRoot("toolTipChildren", DisplayObject(toolTip));
  5.     // hide effect?
  6. }

Monkeypatched code:

  1. public function destroyToolTip(toolTip:IToolTip):void
  2. {
  3.     var sm:ISystemManager = toolTip.systemManager as ISystemManager;
  4.     if(sm.topLevelSystemManager.toolTipChildren.numChildren){//patch to avoid RTE//
  5.         sm.topLevelSystemManager.removeChildFromSandboxRoot("toolTipChildren", DisplayObject(toolTip));
  6.     }
  7.     // hide effect?
  8. }

In addition to correcting my errant destroyToolTip call, this solved any future unknown RTE’s around that issue.

Alternately, if you don’t want to monkeypatch the ToolTipManagerImpl class, you can wrap your destroyToolTip call in a try/catch error block.

Leave a Reply