EasyUI Forum
May 23, 2018, 05:35:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Switching the focus of windows event  (Read 522 times)
erkin
Newbie
*
Posts: 27


View Profile
« on: February 13, 2018, 01:14:46 AM »

Hello!
I can somehow track the event by switching the focus of windows on the title?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3269


View Profile Email
« Reply #1 on: February 13, 2018, 09:24:45 AM »

Try the 'click' event on the window header.
Code:
$('#w').window('header').click(function(){
console.log('click')
})
Logged
erkin
Newbie
*
Posts: 27


View Profile
« Reply #2 on: February 13, 2018, 11:35:57 PM »

Thank you!
Logged
erkin
Newbie
*
Posts: 27


View Profile
« Reply #3 on: February 14, 2018, 06:37:00 AM »

It works.
However, in fact the windows are switched over to mousedown event, not to click.
But the mousedown event does not work in panel title element (<div class="panel-title panel-with-icon">), only in panel header container (<div class="panel-header panel-header-noborder window-header">).

I get this event only at the edges of header container. And the click event does not always work
by windows switching...
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3269


View Profile Email
« Reply #4 on: February 14, 2018, 08:36:48 AM »

Please try this code instead.
Code:
$('#w').window('header').find('.panel-title').mousedown(function(){
console.log('mousedown')
});
Logged
erkin
Newbie
*
Posts: 27


View Profile
« Reply #5 on: February 15, 2018, 12:46:59 AM »

Unfortunately, this does not work.
My code is:
Code:
function onHeaderMouseDown () {
}
$el.dialog('header').find('.panel-title').on('mousedown', onHeaderMouseDown);
In the debugger, permanent errors:
Code:
Uncaught TypeError: Cannot read property 'target' of undefined
    at _43 (jquery.easyui-1.5.1.min.js:444)
    at jquery.easyui-1.5.1.min.js:638
And
Code:
Uncaught TypeError: Cannot read property 'show' of undefined
    at _295 (jquery.easyui-1.5.1.min.js:3701)
    at HTMLDivElement.onDrag (jquery.easyui-1.5.1.min.js:3664)
    at HTMLDocument._49 (jquery.easyui-1.5.1.min.js:484)
    at HTMLDocument.dispatch (jquery.min.js:3)
    at HTMLDocument.q.handle (jquery.min.js:3)

Without a handler, everything works correctly.

I use jQuery EasyUI 1.5.1, jQuery v3.1.0.
« Last Edit: February 15, 2018, 12:49:02 AM by erkin » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3269


View Profile Email
« Reply #6 on: February 16, 2018, 05:23:33 AM »

This is the extended 'onActivate' event that is triggered when clicking on the window header.
Code:
<script type="text/javascript">
(function($){
function fix(target){
var state = $(target).data('window');
var opts = state.options;
$(target).window('window').draggable('options').onBeforeDrag = function(e){
if (state.mask) state.mask.css('z-index', $.fn.window.defaults.zIndex++);
if (state.shadow) state.shadow.css('z-index', $.fn.window.defaults.zIndex++);
state.window.css('z-index', $.fn.window.defaults.zIndex++);
if (opts.onActivate){
opts.onActivate.call(target);
}
}
}

var plugin = $.fn.window;
$.fn.window = function(options, param){
if (typeof options == 'string'){
return plugin.call(this, options, param);
} else {
return this.each(function(){
plugin.call($(this), options, param);
fix(this);
});
}
}
$.fn.window.defaults = plugin.defaults;
$.fn.window.methods = plugin.methods;
$.fn.window.parseOptions = plugin.parseOptions;
$.fn.window.getMaskSize = plugin.getMaskSize;
})(jQuery);

$(function(){
$('#dlg').dialog({
onActivate: function(){
console.log('onActivate')
}
});
})
</script>
Logged
erkin
Newbie
*
Posts: 27


View Profile
« Reply #7 on: February 16, 2018, 07:03:25 AM »

Thanks for the answer, it really works in most cases.  Smiley

However, here we use the method onBeforeDrag.
Dragging is not possible for all areas of the window title:
in attached files it is seen. Dragging works for the central area of header, not for corners
However, windows always switch over the entire header area.  Cry
« Last Edit: February 16, 2018, 07:12:38 AM by erkin » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!