Associates tooltips with HTML elements.
You can get the TooltipManager
via atom.tooltips
.
The essence of displaying a tooltip
// display it
const disposable = atom.tooltips.add(div, {title: 'This is a tooltip'})
// remove it
disposable.dispose()
In practice there are usually multiple tooltips. So we add them to a CompositeDisposable
const [CompositeDisposable](../CompositeDisposable/) = require('atom')
const subscriptions = new CompositeDisposable()
const div1 = document.createElement('div')
const div2 = document.createElement('div')
subscriptions.add(atom.tooltips.add(div1, {title: 'This is a tooltip'}))
subscriptions.add(atom.tooltips.add(div2, {title: 'Another tooltip'}))
// remove them all
subscriptions.dispose()
You can display a key binding in the tooltip as well with the
keyBindingCommand
option.
disposable = atom.tooltips.add(this.caseOptionButton, {
title: 'Match Case',
keyBindingCommand: 'find-and-replace:toggle-case-option',
keyBindingTarget: this.findEditor.element
})
Add a tooltip to the given element.
Argument | Description |
---|---|
|
An |
|
An object with one or more of the following options: |
|
A String or Function to use for the text in the tip. If a function is passed, |
|
A Boolean affecting the interpretation of the |
|
A view (object with an |
|
A String with a class to apply to the tooltip element to enable custom styling. |
|
A String or Function returning a string to indicate the position of the tooltip relative to |
|
A String indicating how the tooltip should be displayed. Choose from one of the following options:
|
|
An object specifying the show and hide delay in milliseconds. Defaults to |
|
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. |
|
An |
Return values |
---|
Returns a Disposable on which |
Find the tooltips that have been applied to the given element.
Argument | Description |
---|---|
|
The |
Return values |
---|
Returns an Array of |