PDA

View Full Version : [CLOSED] Is it possible to hide all shown ToolTips?



RCN
Aug 02, 2013, 1:15 PM
I would like to know whether it's possible to hide all shown ToolTips without forcing a fake click on the document by doing the following:



document.body.fireEvent('onmousedown');

Daniil
Aug 02, 2013, 2:06 PM
Hi Raphael,

I would achieve it this way.

Example


var tooltips = Ext.ComponentQuery.query("tooltip"),
i;

for (i = 0; i < tooltips.length; i++) {
tooltips[i].hide();
}

RCN
Aug 02, 2013, 3:21 PM
Thank you Daniil. Please mark this thread as closed.

RCN
Aug 06, 2013, 2:59 PM
Hi Raphael,

I would achieve it this way.

Example


var tooltips = Ext.ComponentQuery.query("tooltip"),
i;

for (i = 0; i < tooltips.length; i++) {
tooltips[i].hide();
}


I think that the following approach has better performance, because on your approach, the items are first "filtered" and then it's necessary to interate thru them to perform the action.



Ext.ComponentMgr.each(function (componentID, component) {
switch (component.xtype) {
case "tooltip":
case "quicktip":
component.hide();
break;
}
});

Daniil
Aug 06, 2013, 4:26 PM
That is right.

I just gave you a clue;)

Daniil
Aug 06, 2013, 4:39 PM
To be serious, there are some thoughts I would like to share.

Yes, your approach is good and it might give some benefit in performance. Though, very-very minor and not 100%, because of:

1. How many shown tooltips could be there? I think a very few. So, there will be a very few loop iterations.
2. There is the "switch" statement executed for each iteration in your case.
3. Yes, the ComponentQuery's query might be even more heavyweight than that innocent switch statement. Otherwise, there might some optimizations.

So, I cannot be sure what option is really better in performance without measurement. But I think they are almost the same and the difference is insignificant.

Another point.

Assume you create a subclass of ToolTip with, respectively, a new xtype. Your approach will ignore that new tooltip unless you extend the switch statement. My approach will still work.

RCN
Aug 06, 2013, 4:55 PM
To be serious, there are some thoughts I would like to share.

Yes, your approach is good and it might give some benefit in performance. Though, very-very minor and not 100%, because of:

1. How many shown tooltips could be there? I think a very few. So, there will be a very few loop iterations.
2. There is the "switch" statement executed for each iteration in your case.
3. Yes, the ComponentQuery's query might be even more heavyweight than that innocent switch statement. Otherwise, there might some optimizations.

So, I cannot be sure what option is really better in performance without measurement. But I think they are almost the same and the difference is insignificant.

Another point.

Assume you create a subclass of ToolTip with, respectively, a new xtype. Your approach will ignore that new tooltip unless you extend the switch statement. My approach will still work.

I agree with you 100%. Once again, thak you for your considerations.