elisp: Tooltips
37.25 Tooltips
==============
“Tooltips” are special frames (Frames) that are used to display
helpful hints (a.k.a. “tips”) related to the current position of the
mouse pointer. Emacs uses tooltips to display help strings about active
portions of text (Special Properties) and about various UI
elements, such as menu items (Extended Menu Items) and tool-bar
buttons (Tool Bar).
-- Function: tooltip-mode
Tooltip Mode is a minor mode that enables display of tooltips.
Turning off this mode causes the tooltips be displayed in the echo
area. On text-mode (a.k.a. “TTY”) frames, tooltips are always
displayed in the echo area.
When Emacs is built with GTK+ support, it by default displays
tooltips using GTK+ functions, and the appearance of the tooltips is
then controlled by GTK+ settings. GTK+ tooltips can be disabled by
changing the value of the variable ‘x-gtk-use-system-tooltips’ to ‘nil’.
The rest of this subsection describes how to control non-GTK+ tooltips,
which are presented by Emacs itself.
Since tooltips are special frames, they have their frame parameters
(Frame Parameters). Unlike other frames, the frame parameters
for tooltips are stored in a special variable.
-- Variable: tooltip-frame-parameters
This customizable option holds the frame parameters used for
displaying tooltips. Any font and color parameters are ignored,
and the corresponding attributes of the ‘tooltip’ face are used
instead. If ‘left’ or ‘top’ parameters are included, they are used
as absolute frame-relative coordinates where the tooltip should be
shown. (Mouse-relative position of the tooltip can be customized
using the variables described in (emacs)Tooltips.) Note
that the ‘left’ and ‘top’ parameters, if present, override the
values of mouse-relative offsets.
The ‘tooltip’ face determines the appearance of text shown in
tooltips. It should generally use a variable-pitch font of size that is
preferably smaller than the default frame font.
-- Variable: tooltip-functions
This abnormal hook is a list of functions to call when Emacs needs
to display a tooltip. Each function is called with a single
argument EVENT which is a copy of the last mouse movement event.
If a function on this list actually displays the tooltip, it should
return non-‘nil’, and then the rest of the functions will not be
called. The default value of this variable is a single function
‘tooltip-help-tips’.
If you write your own function to be put on the ‘tooltip-functions’
list, you may need to know the buffer of the mouse event that triggered
the tooltip display. The following function provides that information.
-- Function: tooltip-event-buffer event
This function returns the buffer over which EVENT occurred. Call
it with the argument of the function from ‘tooltip-functions’ to
obtain the buffer whose text triggered the tooltip. Note that the
event might occur not over a buffer (e.g., over the tool bar), in
which case this function will return ‘nil’.
Other aspects of tooltip display are controlled by several
customizable settings; see (emacs)Tooltips.