-
16 Aug 2011 10:29 PM #1
Answered: How to: Window that closes when clicked outside of it
Answered: How to: Window that closes when clicked outside of it
How do I have a window that closes itself when the user clicks anywhere outside of it?
-
Best Answer Posted by slemmon
I saw the following (excerpt) in the menu.Manager class the other day. Probably could be used for what you're wanting.
http://docs.sencha.com/ext-js/4-0/so...t-menu-Manager
I bolded the juicy bits. In the window you'd set a cls property to watch for and then just reference it in the red conditional below.
Code:onHide: function(m) { var me = this, active = me.active; active.remove(m); if (active.length < 1) { Ext.getDoc().un('mousedown', me.onMouseDown, me); me.attached = false; } }, onShow: function(m) { var me = this, active = me.active, last = active.last(), attached = me.attached, menuEl = m.getEl(), zIndex; me.lastShow = new Date(); active.add(m); if (!attached) { Ext.getDoc().on('mousedown', me.onMouseDown, me); me.attached = true; } m.toFront(); },Code:onMouseDown: function(e) { var me = this, active = me.active, lastShow = me.lastShow; if (Ext.Date.getElapsed(lastShow) > 50 && active.length > 0 && !e.getTarget('.' + Ext.baseCSSPrefix + 'menu')) { me.hideAll(); } },
-
17 Aug 2011 11:07 AM #2
I saw the following (excerpt) in the menu.Manager class the other day. Probably could be used for what you're wanting.
http://docs.sencha.com/ext-js/4-0/so...t-menu-Manager
I bolded the juicy bits. In the window you'd set a cls property to watch for and then just reference it in the red conditional below.
Code:onHide: function(m) { var me = this, active = me.active; active.remove(m); if (active.length < 1) { Ext.getDoc().un('mousedown', me.onMouseDown, me); me.attached = false; } }, onShow: function(m) { var me = this, active = me.active, last = active.last(), attached = me.attached, menuEl = m.getEl(), zIndex; me.lastShow = new Date(); active.add(m); if (!attached) { Ext.getDoc().on('mousedown', me.onMouseDown, me); me.attached = true; } m.toFront(); },Code:onMouseDown: function(e) { var me = this, active = me.active, lastShow = me.lastShow; if (Ext.Date.getElapsed(lastShow) > 50 && active.length > 0 && !e.getTarget('.' + Ext.baseCSSPrefix + 'menu')) { me.hideAll(); } },
-
17 Aug 2011 7:21 PM #3


Reply With Quote