Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent Windows Focus Issue even though Focus set to false #6457

Closed
uppuluriaditya opened this issue Feb 6, 2018 · 1 comment
Closed

Comments

@uppuluriaditya
Copy link

uppuluriaditya commented Feb 6, 2018

Hi All,
Our company is using nw 20.0 version for our application and we have a customer issue where 'stealing focus' has become the biggest issue. I'm able to replicate the problem intermittently and once it gets reproduced, I was able to see the problem persisting on all NW versions. To get away with the problem, I had to restart my computer.
Here is the problem:
When the application is running, I had opened notepad/word/some other editor where I am typing something. Our app has desktop notification feature. So, when any notification comes, the notification window is stealing the focus away from notepad.

NWJS Version : Any latest version (Was intermittently able to reproduce on all versions. Tried in 20.0, 27.4)
Operating System : Windows7, 8 and 10
I have a sample code using which, i am able to reproduce the problem. Here is the sample code

var NOTIFICATION_WIDTH = 460,
       NOTIFICATION_HEIGHT = 141;
  var openNewWindow = function(){
	console.log("new window");
	var v= setTimeout(function(){
	var url = "jQueryPage.html";
	nw.Window.open(url, {
		show: false,
                focus: false,
                width: NOTIFICATION_WIDTH,
                height: NOTIFICATION_HEIGHT,
                show_in_taskbar: true,
                frame: false,
                transparent: true
	        }, function(new_win){
		     console.log("Window created");
		     new_win.name = 'notification_window';
		     new_win.setAlwaysOnTop(true);
		     new_win.moveTo(nw.Screen.screens[0].work_area.width - NOTIFICATION_WIDTH,
                         (nw.Screen.screens[0].work_area.height - (NOTIFICATION_HEIGHT)));
                     new_win.on('loaded', function() {
                             new_win.show(true);
                     });
		     new_win.on('close', function() {
                             console.info('CLOSE');
			     new_win.close(true);
                     });
		      new_win.on('focus', function(){
			  console.log('New window Focused')
		      })
	       }
	);
	}, 5000);
};

Extremely sorry if the code indentation is poor. As you see in the above code, I'm not using Focus function on the new window but still it is taking the focus.
Can someone help me in understand the issue?

Let me know if i can provide you with anymore information

Note: The JQueryPage.html page is just a simple html page.

@uppuluriaditya
Copy link
Author

Closing this issue as I found a workaround (link) . Instead of calling show() function when necessary, I am initialising the window with (0,0) and then resizing it once loaded

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant