blob: 7cd07e7365ced5a8bd65715ad10200749bb843fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
License:
LGPL: http://www.gnu.org/licenses/lgpl.html
EPL: http://www.eclipse.org/org/documents/epl-v10.php
See the LICENSE file in the project's top-level directory for details.
Authors:
* Sebastian Werner (wpbasti)
* Andreas Ecker (ecker)
************************************************************************ */
/* ************************************************************************
#module(ui_popup)
************************************************************************ */
/*!
This manages ToolTip instances
*/
qx.OO.defineClass("qx.manager.object.ToolTipManager", qx.manager.object.ObjectManager,
function() {
qx.manager.object.ObjectManager.call(this);
});
qx.OO.addProperty({ name : "currentToolTip", type : "object", instance : "qx.ui.popup.ToolTip" });
/*
---------------------------------------------------------------------------
MODIFIER
---------------------------------------------------------------------------
*/
qx.Proto._modifyCurrentToolTip = function(propValue, propOldValue, propData)
{
// Return if the new tooltip is a child of the old one
if(propOldValue && propOldValue.contains(propValue)) {
return;
}
// If old tooltip existing, hide it and clear widget binding
if(propOldValue)
{
propOldValue.hide();
propOldValue._stopShowTimer();
propOldValue._stopHideTimer();
}
// If new tooltip is not null, set it up and start the timer
if(propValue) {
propValue._startShowTimer();
}
return true;
}
/*
---------------------------------------------------------------------------
EVENT INTERFACE: MOUSE
---------------------------------------------------------------------------
*/
qx.Proto.handleMouseOver = function(e)
{
var vTarget = e.getTarget();
var vToolTip;
// Allows us to use DOM Nodes as tooltip target :)
if (!(vTarget instanceof qx.ui.core.Widget) && vTarget.nodeType == 1) {
vTarget = qx.event.handler.EventHandler.getTargetObject(vTarget);
}
//Search first parent which has a tooltip
while(vTarget != null && !(vToolTip = vTarget.getToolTip())) {
vTarget = vTarget.getParent();
}
// Bind tooltip to widget
if (vToolTip != null) {
vToolTip.setBoundToWidget(vTarget);
}
// Set Property
this.setCurrentToolTip(vToolTip);
}
qx.Proto.handleMouseOut = function(e)
{
var vTarget = e.getTarget();
var vRelatedTarget = e.getRelatedTarget();
var vToolTip = this.getCurrentToolTip();
// If there was a tooltip and
// - the destination target is the current tooltip
// or
// - the current tooltip contains the destination target
if(vToolTip && (vRelatedTarget == vToolTip || vToolTip.contains(vRelatedTarget))) {
return;
}
// If the destination target exists and the target contains it
if(vRelatedTarget && vTarget && vTarget.contains(vRelatedTarget)) {
return;
}
// If there was a tooltip and there is no new one
if(vToolTip && !vRelatedTarget) {
this.setCurrentToolTip(null);
}
}
/*
---------------------------------------------------------------------------
EVENT INTERFACE: FOCUS
---------------------------------------------------------------------------
*/
qx.Proto.handleFocus = function(e)
{
var vTarget = e.getTarget();
var vToolTip = vTarget.getToolTip();
// Only set new tooltip if focus widget
// has one
if(vToolTip != null)
{
// Bind tooltip to widget
vToolTip.setBoundToWidget(vTarget);
// Set Property
this.setCurrentToolTip(vToolTip);
}
}
qx.Proto.handleBlur = function(e)
{
var vTarget = e.getTarget();
if(!vTarget) {
return;
}
var vToolTip = this.getCurrentToolTip();
// Only set to null if blured widget is the
// one which has created the current tooltip
if(vToolTip && vToolTip == vTarget.getToolTip()) {
this.setCurrentToolTip(null);
}
}
/*
---------------------------------------------------------------------------
DEFER SINGLETON INSTANCE
---------------------------------------------------------------------------
*/
/**
* Singleton Instance Getter
*/
qx.Class.getInstance = qx.lang.Function.returnInstance;
|