Skip to content

Commit

Permalink
Improved escape behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Apr 30, 2021
1 parent 5e38d64 commit 78518e7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions modules/feature/minimize.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,23 @@ export default class MinimalUIMinimize {

static initHooks() {

$(document).keydown((event) => {
// 27 == Escape
if (event.which === 27) {
if (Object.keys(MinimalUIMinimize.minimizedStash).length > 0) {
MinimalUIMinimize.cleanupMinimizeBar(undefined, true);
}
}

});

Hooks.once('ready', async function() {
const setting = game.settings.get('minimal-ui', 'organizedMinimize');
if (['topBar', 'bottomBar'].includes(setting))
MinimalUIMinimize.positionMinimizeBar();
if (setting !== 'disabled') {

libWrapper.register('minimal-ui', 'KeyboardManager.prototype._onEscape', function (wrapped, ...args) {
let [_, up, modifiers] = args;
if ( up || modifiers.hasFocus ) return wrapped(...args);
else if ( !(ui.context && ui.context.menu.length) ) {
if ( Object.keys(MinimalUIMinimize.minimizedStash).length > 0) {
MinimalUIMinimize.cleanupMinimizeBar(undefined, true);
}
}
return wrapped(...args);
}, 'WRAPPER');

libWrapper.register('minimal-ui', 'Application.prototype.minimize', async function (wrapped, ...args) {
const targetHtml = $(`[data-appid='${this.appId}']`);
targetHtml.css('visibility', 'hidden');
Expand Down

0 comments on commit 78518e7

Please sign in to comment.