fix #1096: focus issues after minimizing

This commit is contained in:
antelle 2019-02-04 19:20:12 +01:00
parent 28c9faf48f
commit e79e903f25
3 changed files with 17 additions and 6 deletions

View File

@ -1,3 +1,4 @@
const Backbone = require('backbone');
const FeatureDetector = require('../util/feature-detector');
const Launcher = require('../comp/launcher');
@ -5,10 +6,14 @@ const FocusDetector = {
init() {
this.isFocused = true;
this.detectsFocusWithEvents = !FeatureDetector.isDesktop && !FeatureDetector.isMobile;
if (this.detectsFocusWithEvents) {
window.onblur = () => { this.isFocused = false; };
window.onfocus = () => { this.isFocused = true; };
}
window.onfocus = () => {
this.isFocused = true;
Backbone.trigger('focus');
};
window.onblur = () => {
this.isFocused = false;
Backbone.trigger('blur');
};
},
hasFocus() {

View File

@ -69,6 +69,7 @@ const OpenView = Backbone.View.extend({
KeyHandler.onKey(Keys.DOM_VK_RETURN, this.enterKeyPress, this);
KeyHandler.onKey(Keys.DOM_VK_DOWN, this.moveOpenFileSelectionDown, this);
KeyHandler.onKey(Keys.DOM_VK_UP, this.moveOpenFileSelectionUp, this);
this.listenTo(Backbone, 'focus', this.windowFocused.bind(this));
},
render: function () {
@ -105,10 +106,12 @@ const OpenView = Backbone.View.extend({
return this;
},
windowFocused: function() {
this.inputEl.focus();
},
focusInput: function() {
console.log('focus');
if (FocusDetector.hasFocus()) {
console.log('hasFocus');
this.inputEl.focus();
}
},

View File

@ -1,5 +1,8 @@
Release notes
-------------
##### v1.7.5 (2019-02-05)
`-` fix #1096: focus issues after minimizing
##### v1.7.4 (2019-01-17)
`-` fix #423: input focus issues in desktop apps