Top |
This is a base class for other tooltip items to inherit. This cannot be instantiated.
All other tooltip items inherit this object. This base class is responsible for listening to mouse events and determining when to show the tooltip. When it thinks a tooltip should be shown, it calls this.show()
. When it thinks it should be hidden, it calls this.hide()
. When the item
is destroyed, it will call this._destroy()
;
Any object wishing to implement a tooltip should inherit this class, and then implement the three functions above. It should be noted that the sole responsibility of this class is to call the three functions above. It is thus the user's job to create the tooltip actor and position it correctly in the show
function. Example implementations for reference include the Tooltips.Tooltip
object as well as the WindowPreview
object in the window list applet.
When calling the show
function, TooltipBase
will set the this.mousePosition
to the mouse coordinates at which the event is triggered.
When implementing the show
and hide
functions, the user should set the this.visible
variable to the visibility state of the tooltip. This is since calling the show
function does not necessarily actually show the tooltip, eg. when the tooltip text is empty and the tooltip refuses to show. The this.visible
variable should be set properly to reflect the actual status of the tooltip.
Finally, if the user wishes to inhibit the display of a tooltip, eg. when the owner is being dragged, they can set the this.preventShow
variable to true
.