PDA

View Full Version : [OPEN] [Feature Request] Render windows without focus them



steffenk
25 Feb 2011, 10:28 AM
Hi,

i have the situation that i render a bunch of windows in a container that scrolls. If i do so, it takes a lot of time because each window rendered gets focus, the container scroll jumps a lot and this doesn't look nice.

Render the windows without focus mage render process up to 4 times faster and looks much better. So fucus window for a single window is okay, but mass action is horrible.

The following override was done by me to achieve it, it's very simple, and i use a property in Window
noFocus: true

Here is the override:


Ext.override(Ext.Window, {
afterShow : function(isAnim) {
if (this.isDestroyed) {
return false;
}
this.proxy.hide();
this.el.setStyle('display', 'block');
this.el.show();
if (this.maximized) {
this.fitContainer();
}
if (Ext.isMac && Ext.isGecko2) {
this.cascade(this.setAutoScroll);
}

if (this.monitorResize || this.modal || this.constrain || this.constrainHeader) {
Ext.EventManager.onWindowResize(this.onWindowResize, this);
}
this.doConstrain();
this.doLayout();
if (this.keyMap) {
this.keyMap.enable();
}
if (!this.noFocus) {
this.toFront();
}
this.updateHandles();
if (isAnim && (Ext.isIE || Ext.isWebKit)) {
var sz = this.getSize();
this.onResize(sz.width, sz.height);
}
this.onShow();
this.fireEvent('show', this);
}
});

I would love to see this in EXT4, also as this is a very small and easy change.

Animal
25 Feb 2011, 10:58 AM
You should be able to configure your Window with



focus: Ext.emptyFn


and it won't be able to focus itself.

steffenk
25 Feb 2011, 3:17 PM
Hi Nige,

if i do so i lose focus functionality of the window. i only want to exclude it while render.
So maybe naming of the property is misleading, should read
noFocusOnRender

Animal
25 Feb 2011, 3:38 PM
Probably better would be to have a special value of the defaultFocus config which specifies no focussing.

This is what used to be the defaultButton config, and specifies a Component to focus upon focusing the Window.

I'll look at ways of specifying "do not focus anything", and document any solution on the defaultFocus config option.

steffenk
25 Feb 2011, 3:51 PM
thanks!

Animal
25 Feb 2011, 4:15 PM
OK, thinking about this more, what you need if you are showing (with autoRender on first show) a bunch of Windows is for the last Window to focus itself, not each one as it is shown.

I think the best thing is that the focus task be buffered, so that if another Window requests focus for itself within 1 few milliseconds, the first focus is canceled.

That way, after showing 10 Windows, only the automatic focus for the last Window will be processed. This seems like the best solution, requires no configs, and makes the most sense intuitively.

Animal
25 Feb 2011, 4:37 PM
OK, it's much better now. There used to be an Ext.util.DelayedTask set up in every Component to handle delayed focus.

Now there's just one shared by all Components.

Because obviously, only ONE component can actually have focus at any one time! So the last one to request focus gets it, and any others focused in one contiguous set of focus() calls never actually get focus; their delayed focus request gets cancelled.

steffenk
25 Feb 2011, 5:06 PM
could you share your code for this solution, if you already have some? I got the idea, but don't see how to do it easy (eg "Now there's just one shared by all Components") - how do you integrate it?

Animal
25 Feb 2011, 5:39 PM
You'll have to wait and see.... ;)

Only a few days until the next preview.

steffenk
26 Feb 2011, 2:03 AM
ok :)

btw - it's not needed to focus last window. In my case i render windows from top to bottom, and i don't want to focus the last window - just none. The container should stay with scrollTop 0 and user can scroll and focus any by click

Animal
26 Feb 2011, 8:49 AM
Just call



myWin.focusTask.cancel();


after showing the last Window, and its queued focus call will be canceled.

steffenk
26 Feb 2011, 9:06 AM
cool :)