PDA

View Full Version : Center a window respect to the root window (I've extended Ext.air.NativeWindow)



iDave
14 Jun 2008, 11:20 AM
I saw that the Ext air api, provides methods for center a window respect to the screen, but there
isn't a simple method to center a window respect to the main root window...

so, I've extended the Ext.air.NativeWindow class, by adding a method called "centerToRootWindow":

Ext.air.NativeWindow.prototype.centerToRootWindow = function(w) {
var rw = w || air.NativeApplication.nativeApplication.openedWindows[0];
this.moveTo(rw.x+rw.width/2-this.width/2, rw.y+rw.height/2-this.height/2);
}

It works as I wanted... I hope someone can find my work helpful, and that maybe it will be
included in the future release of Ext... it would be an honor :)