<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://cegui.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Klapeto</id>
		<title>CEGUI Wiki - Crazy Eddie's GUI System (Open Source) - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://cegui.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Klapeto"/>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/Special:Contributions/Klapeto"/>
		<updated>2026-04-29T11:30:42Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Tooltips&amp;diff=5551</id>
		<title>Tooltips</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Tooltips&amp;diff=5551"/>
				<updated>2014-11-11T00:04:39Z</updated>
		
		<summary type="html">&lt;p&gt;Klapeto: Fixed Code to work with new CEGUI Version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.5}} {{VersionBadge|0.6}}&lt;br /&gt;
&lt;br /&gt;
I am not an expert but I would like to share what I have learned and gleaned about the ''Tooltip'' widget.&lt;br /&gt;
&lt;br /&gt;
API References:&lt;br /&gt;
[http://www.cegui.org.uk/api_reference/classCEGUI_1_1Tooltip.html Tooltip]&lt;br /&gt;
[http://www.cegui.org.uk/api_reference/classCEGUI_1_1System.html System]&lt;br /&gt;
&lt;br /&gt;
As you would expect, the ''Tooltip'' works very similar to most tooltip systems. Basically the user hovers the mouse over a CEGUI widget and when a specified time has elapsed the tooltip is displayed for a specified amount of time. As with most of the CEGUI widgets the ''Tooltip'' widget is based upon the CEGUI ''Window'' class widget.&lt;br /&gt;
&lt;br /&gt;
''Please note that the following example source code was gleaned and edited from project specific code so there may be some syntax errors.''&lt;br /&gt;
&lt;br /&gt;
== Creating the Default System ''Tootip'' widget ==&lt;br /&gt;
&lt;br /&gt;
CEGUI will manage a single default, system wide ''Tooltip'' widget for you that will take care of displaying your tooltip text. You have to initialize it by calling '''CEGUI::System::setDefaultTooltip()'' one time, somehwere in your code. I would recommend calling this right after initializing the CEGUI system. Here's a sample call:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  // Create default ToolTip item&lt;br /&gt;
  CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltip( (CEGUI::utf8*)&amp;quot;TaharezLook/Tooltip&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Yep, that's all there is too it.&lt;br /&gt;
In newer versions of CEGUI the method has been renamed to setDefaultTooltip for consistency.&lt;br /&gt;
&lt;br /&gt;
== Setting the ''Tootip'' text to display ==&lt;br /&gt;
&lt;br /&gt;
There are two methods for setting your tooltip text: In your code or in your layout file.&lt;br /&gt;
&lt;br /&gt;
'''Setting the ''Tooltip'' text in your code'''&lt;br /&gt;
&lt;br /&gt;
You can hardcode toolip text in your code by using the ''WindowObject::setTooltipText()'' function like so:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::PushButton *mPushButton = (CEGUI::PushButton *)mWinMgr-&amp;gt;createWindow(&lt;br /&gt;
(CEGUI::utf8*)&amp;quot;TaharezLook/PushButton&amp;quot;, (CEGUI::utf8*)&amp;quot;PushButton&amp;quot;);&lt;br /&gt;
// Set other properties like size, position, etc.&lt;br /&gt;
mPushButton-&amp;gt;setTooltipText(&amp;quot;This is a tooltip.&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Setting the ''Tooltip'' text in your layout (xml) file'''&lt;br /&gt;
&lt;br /&gt;
The prefered method is to set the tooltip text in your layout file and you can do it like so:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;Window Type=&amp;quot;TaharezLook/Editbox&amp;quot; Name=&amp;quot;Login/EditBox/Password&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;Property Name=&amp;quot;AbsoluteRect&amp;quot; Value=&amp;quot;l:128.000000 t:0.000000 r:486.000000 b:46.000000&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Property Name=&amp;quot;AlwaysOnTop&amp;quot; Value=&amp;quot;True&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Property Name=&amp;quot;RelativeRect&amp;quot; Value=&amp;quot;l:0.250000 t:0.000000 r:0.950000 b:1.000000&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Property Name=&amp;quot;Text&amp;quot; Value=&amp;quot;{Enter Password Here}&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Property Name=&amp;quot;Tooltip&amp;quot; Value=&amp;quot;Enter your password here.&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/Window&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Ensure that the Tooltip is registered in your .Scheme file'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;WindowSet Filename=&amp;quot;CEGUITaharezLook&amp;quot;&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;WindowFactory Name=&amp;quot;TaharezLook/Tooltip&amp;quot; /&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/WindowSet&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Ensure that imageset contains graphics for the Tooltip'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;Imageset Name=&amp;quot;TaharezLook&amp;quot; Imagefile=&amp;quot;TaharezLook.png&amp;quot; NativeHorzRes=&amp;quot;800&amp;quot; NativeVertRes=&amp;quot;600&amp;quot; AutoScaled=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipLeftEdge&amp;quot; XPos=&amp;quot;217&amp;quot; YPos=&amp;quot;225&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipRightEdge&amp;quot; XPos=&amp;quot;246&amp;quot; YPos=&amp;quot;225&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipTopEdge&amp;quot; XPos=&amp;quot;224&amp;quot; YPos=&amp;quot;218&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipBottomEdge&amp;quot; XPos=&amp;quot;224&amp;quot; YPos=&amp;quot;248&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipTopLeft&amp;quot; XPos=&amp;quot;217&amp;quot; YPos=&amp;quot;218&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipTopRight&amp;quot; XPos=&amp;quot;246&amp;quot; YPos=&amp;quot;218&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipBottomLeft&amp;quot; XPos=&amp;quot;217&amp;quot; YPos=&amp;quot;248&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipBottomRight&amp;quot; XPos=&amp;quot;246&amp;quot; YPos=&amp;quot;248&amp;quot; Width=&amp;quot;7&amp;quot; Height=&amp;quot;7&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Image Name=&amp;quot;TooltipMiddle&amp;quot; XPos=&amp;quot;2&amp;quot; YPos=&amp;quot;2&amp;quot; Width=&amp;quot;64&amp;quot; Height=&amp;quot;64&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/Imageset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to display the ''Tooltip'' ==&lt;br /&gt;
&lt;br /&gt;
'''Inject Time Pulse'''&lt;br /&gt;
&lt;br /&gt;
This is a very important piece of information that is not well documented in the current CEGUI system: ''Time Pulse Injection''. The CEGUI system, to my knowledge, does not keep track of time for you by itself - it needs help. You must inject into the CEGUI System elapsed time. If you don't do this, then your ''Tooltip'' and other time sensitive window events (like fades, etc) will not work or will not work properly. What is the ''value'' you inject? The ''value'' should be the amount of time that has elapsed since the previous injection call. Both CEGUI::System and GUI Contextes must be injected. The best place to inject a time pulse into the CEGUI is in a main loop. Here are a couple of examples of how to implement this:&lt;br /&gt;
&lt;br /&gt;
'''Inject Time Pulse: via a MAIN Loop'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
clock_t mLastTimeInjection=clock();&lt;br /&gt;
...&lt;br /&gt;
// Your main loop&lt;br /&gt;
while ( true )&lt;br /&gt;
{&lt;br /&gt;
  ...&lt;br /&gt;
  // Make sure the CEGUI System is initialized and running&lt;br /&gt;
  // and if it is, inject a time pulse&lt;br /&gt;
  if ( CEGUI::System::getSingletonPtr() )&lt;br /&gt;
  {&lt;br /&gt;
    clock_t now = clock();&lt;br /&gt;
    CEGUI::System::getSingleton().injectTimePulse( ( now - mLastTimeInjection ) * 0.001f );&lt;br /&gt;
    CEGUI::System::getSingleton().getDefaultGUIContext().injectTimePulse( ( now - mLastTimeInjection ) * 0.001f );&lt;br /&gt;
    mLastTimeInjection = clock();&lt;br /&gt;
  } // CEGUI Time pulse&lt;br /&gt;
  ...&lt;br /&gt;
} // while&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Inject Time Pulse: In C++11'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;chrono&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
typedef std::chrono::duration&amp;lt;float, std::chrono::seconds::period&amp;gt; fpTime;&lt;br /&gt;
std::chrono::high_resolution_clock::time_point last_time=std::chrono::high_resolution_clock::now();&lt;br /&gt;
...&lt;br /&gt;
// Your main loop&lt;br /&gt;
while ( true ){&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::System&amp;amp; system = CEGUI::System::getSingleton();&lt;br /&gt;
       auto begin = std::chrono::high_resolution_clock::now();&lt;br /&gt;
       float elapsed = fpTime(begin - last_time).count();&lt;br /&gt;
&lt;br /&gt;
       system.injectTimePulse( elapsed );&lt;br /&gt;
       system.getDefaultGUIContext().injectTimePulse( elapsed );&lt;br /&gt;
       &lt;br /&gt;
       last_time = begin;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
} // while&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Inject Time Pulse: via an Ogre::FrameListenter'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bool clsMyFrameListener::frameStarted(const Ogre::FrameEvent&amp;amp; evt)&lt;br /&gt;
{ &lt;br /&gt;
  ...&lt;br /&gt;
  // Make sure the CEGUI System is initialized and running&lt;br /&gt;
  // and if it is, inject a time pulse&lt;br /&gt;
  if ( CEGUI::System::getSingletonPtr() )&lt;br /&gt;
    CEGUI::System::getSingleton().injectTimePulse( evt.timeSinceLastFrame)&lt;br /&gt;
    CEGUI::System::getSingleton().getDefaultGUIContext().injectTimePulse( evt.timeSinceLastFrame );&lt;br /&gt;
  ...&lt;br /&gt;
  return true;&lt;br /&gt;
} //frameStarted&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The finer the resolution of the injection, the better your fades will look. Injecting time every one second or greater will make your ''fades'' just popup instead of ''fading'' in.&lt;br /&gt;
&lt;br /&gt;
== How to offset the ''Tooltip'' so it doesn't render under the mouse ==&lt;br /&gt;
&lt;br /&gt;
'''Via LookNFeel animation'''&lt;br /&gt;
&lt;br /&gt;
One way to do this is to edit your scheme's looknfeel and change the Tooltip's FadeIn animation to affect the Position property too.&lt;br /&gt;
If the tooltip doesn't have a FadeIn animation, just add one.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;WidgetLook name=&amp;quot;TaharezLook/Tooltip&amp;quot;&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
        &amp;lt;AnimationDefinition name=&amp;quot;FadeIn&amp;quot; duration=&amp;quot;0.33&amp;quot; replayMode=&amp;quot;once&amp;quot;&amp;gt;&lt;br /&gt;
            ...&lt;br /&gt;
            &amp;lt;Affector property=&amp;quot;Position&amp;quot; interpolator=&amp;quot;UVector2&amp;quot; applicationMethod=&amp;quot;relative&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;KeyFrame position=&amp;quot;0&amp;quot; value=&amp;quot;{{0,12},{0,0}}&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/Affector&amp;gt;&lt;br /&gt;
            ...&lt;br /&gt;
        &amp;lt;/AnimationDefinition&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
    &amp;lt;/WidgetLook&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This will offset the tooltip's x by 12 pixels (in my case, that's how wide my system mouse cursor is -- modify to suit your needs).&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
That's really all there is to it. My biggest ''gotcha'' was the not knowing about the ''CEGUI::System::injectTimePulse()'' and how important it was. Once I stumbled upon that everything else fell into place.&lt;br /&gt;
&lt;br /&gt;
Some advanced notes. You can have more than one ''Tooltip'' widget. There maybe some scenerios where just one ''Tooltip'' widget won't work (like for a different look and feel from that of the default one, etc.). You can create another ''Tooltip'' widget using the standard CEGUI method for creating all the window widgets then use the ''CEGUI::Window::setToolTip()'' function to set the widget to use the desired ''Tooltip''.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Update requested]]&lt;/div&gt;</summary>
		<author><name>Klapeto</name></author>	</entry>

	</feed>