PDA

View Full Version : Prevent another window fire their event when dragging



njentit
12 Sep 2008, 11:48 AM
my application have some bug when user drag the window, dragging is not smooth
another window fire their event when dragged over it.
my currently solution is add some code so all other window get ghosted while dragging.
changed file Window.js :



Ext.extend(Ext.Window.DD, Ext.dd.DD, {
moveOnly:true,
headerOffsets:[100, 25],
startDrag : function(){
var w = this.win;

// added by njentit
w.manager.each(function(wx){
if(wx.id!=w.id){
wx.dd.proxy = wx.ghost();
}
});
//end

this.proxy = w.ghost();
if(w.constrain !== false){
var so = w.el.shadowOffset;
this.constrainTo(w.container, {right: so, left: so, bottom: so});
}else if(w.constrainHeader !== false){
var s = this.proxy.getSize();
this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
}
},
b4Drag : Ext.emptyFn,

onDrag : function(e){
this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
},

endDrag : function(e){
// added by njentit
this.win.manager.each(function(wx){
if(wx.id!=this.id){
wx.unghost();
//wx.saveState();
}
},this.win);
//end

this.win.unghost();
this.win.saveState();
}
});


i hope this help who have similar problem.

Animal
13 Sep 2008, 1:01 AM
Try the following override instead:



Ext.override(Ext.Window, {
initDraggable : function(){
/**
* If this Window is configured {@link #draggable}, this property will contain
* an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.
* @type Ext.dd.DD
* @property dd
*/
this.dd = new Ext.Window.DD(this);
this.dd.moveOnly = true;
}
});


If this fixes the performance problems, then post a bug report with the suggested fix.

Animal
15 Sep 2008, 12:22 AM
Did the above suggestion fix your problem? Because If so, it needs to be applied to the Ext source.

njentit
15 Sep 2008, 7:15 PM
Did the above suggestion fix your problem? Because If so, it needs to be applied to the Ext source.
Yes that solve my windowing problem.
My application is highly depend on managed iframe that load another page as module on my application.
Another developer could implement the module with their own event listener, that fire the problem.
With those little update my application working till now without any problem on window dragging.
And now i'm going to buy license to use extjs as part of my commercial application.

Animal
16 Sep 2008, 2:19 AM
OK, I have submitted this as a bug report. Moving a Window should not activate the DD objects of any other moveable Windows.

mschwartz
2 Mar 2009, 10:36 AM
It'd be nice if Window had a beforemove (not beforeremove!) event, so you could shim all your iframes before allowing the window to be dragged, or otherwise decide to not allow the window to be dragged or whatever.

Before Move.

In fact, looking at DragDrop, it's odd that it calls abstract functions like beginDrag() instead of firing events like a well behaved Ext thingy.

mschwartz
2 Mar 2009, 10:52 AM
Ext.override(Ext.Window.DD, {
startDrag: function() {
Ext.ux.ManagedIFrame.Manager.showShims()
var w = this.win;
this.proxy = w.ghost();
if(w.constrain !== false){
var so = w.el.shadowOffset;
this.constrainTo(w.container, {right: so, left: so, bottom: so});
}else if(w.constrainHeader !== false){
var s = this.proxy.getSize();
this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
}
},
endDrag : function(e){
Ext.ux.ManagedIFrame.Manager.hideShims();
this.win.unghost();
this.win.saveState();
}
});
Note: the smilies on the right of this editor are messed up for me: