GUI Scripting:Tooltip Macro
This page is part of a series. See GUI Scripting Language for overview.
Introduction
Specific to TDM's main menu system, a macro offers a simple way to provide an internationalized tooltip, invoked by guiDef mouse-over. The tooltip appears, not over the guiDef, but in a fixed screen location, offset to the left of the current menu. Syntax:
toolTip ("string")
Note the parentheses around the quoted string, and no semicolon at the end. As a specific example:
toolTip("#str_menu_fov_tooltip")
This macro expands into event handlers and so should be placed after the Property List. Usually, it is placed at the end of the guiDef's body, after any other event handlers.
Caution
This macro expands into OnMouseEnter and OnMouseExit event handlers... so if you have those same handlers elsewhere in your guiDef, you may need check for conflicts and/or merge handler bodies manually, using showTopTip(...) and hideTooltip(). See windowDef SettingsRestartGameAction in mainmenu_settings.gui for an example.
Also, "noevents 1" should not be set in your guiDef.
Implementation
In mainmenu_utils.gui, which is included with other main menu GUIs:
... windowDef ToolTip { rect 16, 360 , 288, 120 visible "gui::tdm_show_menu_tooltips" float active; windowDef ToolTipText { rect 00, 10, 280, 80 MM_TT_FONT textscale 0.2 } } #define showToolTip(TTtext)\ set "ToolTipText::text" TTtext #define hideToolTip\ set "ToolTipText::text" "" #define toolTip(TTtext)\ onMouseEnter\ {\ showToolTip(TTtext);\ }\ onMouseExit\ {\ hideToolTip;\ }