TooltipManager essential
Associates tooltips with HTML elements.
You can get the TooltipManager
via atom.tooltips
.
Examples
The essence of displaying a tooltip
# display itdisposable = atomtooltipsadddivtitle: 'This is a tooltip'# remove itdisposabledispose
In practice there are usually multiple tooltips. So we add them to a CompositeDisposable
require 'atom'subscriptions =div1 = documentcreateElement'div'div2 = documentcreateElement'div'subscriptionsadd atomtooltipsadddiv1title: 'This is a tooltip'subscriptionsadd atomtooltipsadddiv2title: 'Another tooltip'# remove them allsubscriptionsdispose
You can display a key binding in the tooltip as well with the
keyBindingCommand
option.
disposable = atomtooltipsadd @caseOptionButtontitle: "Match Case"keyBindingCommand: 'find-and-replace:toggle-case-option'keyBindingTarget: @findEditorelement
Methods
::add(target, options)
Add a tooltip to the given element.
Argument | Description |
---|---|
target |
An |
options |
An object with one or more of the following options: |
title |
A String or Function to use for the text in the tip. If a function is passed, |
html |
A Boolean affecting the interpretation of the |
item |
A view (object with an |
class |
A String with a class to apply to the tooltip element to enable custom styling. |
placement |
A String or Function returning a string to indicate the position of the tooltip relative to |
trigger |
A String indicating how the tooltip should be displayed. Choose from one of the following options:
|
delay |
An object specifying the show and hide delay in milliseconds. Defaults to |
keyBindingCommand |
A String containing a command name. If you specify this option and a key binding exists that matches the command, it will be appended to the title or rendered alone if no title is specified. |
keyBindingTarget |
An |
Return values |
---|
Returns a Disposable on which |
::findTooltips(target)
Find the tooltips that have been applied to the given element.
Argument | Description |
---|---|
target |
The |
Return values |
---|
Returns an Array of |