Fix multiple dialogs focus bug

This commit is contained in:
DanyLE 2022-05-24 17:35:27 +02:00
parent c2e72a067e
commit c26e27d7ec
4 changed files with 57 additions and 9 deletions

14
d.ts/antos.d.ts vendored
View File

@ -380,10 +380,11 @@ declare namespace OS {
*
* Need to be implemented by subclasses
*
* @abstract
* @memberof SubWindow
*
* @returns {void}
* @memberof BaseDialog
*/
abstract init(): void;
init(): void;
/**
* Main entry point after rendering of the sub-window
*
@ -412,6 +413,13 @@ declare namespace OS {
* @memberof SubWindow
*/
hide(): void;
/**
* blur the sub-window
*
* @returns {void}
* @memberof SubWindow
*/
blur(): void;
}
/**
* Abstract prototype of all AntOS dialogs widget

Binary file not shown.

View File

@ -362,7 +362,11 @@ namespace OS {
if (this.appmenu && this.pid === this.appmenu.pid) {
this.appmenu.items = [];
}
return this.trigger("blur", undefined);
this.trigger("blur", undefined);
if(this.dialog)
{
this.dialog.blur();
}
}
/**

View File

@ -44,6 +44,7 @@ namespace OS {
*/
parent: BaseModel | typeof GUI;
/**
*Creates an instance of SubWindow.
* @param {string} name SubWindow (class) name
@ -82,10 +83,26 @@ namespace OS {
*
* Need to be implemented by subclasses
*
* @abstract
* @memberof SubWindow
*
* @returns {void}
* @memberof BaseDialog
*/
abstract init(): void;
init(): void {
// show the app if it is not active
this.on("focus",() => {
if((this.pid == -1) || (PM.pidactive == this.pid))
{
return;
}
const app = PM.appByPid(this.pid);
if(app)
{
app.show();
}
});
}
/**
* Main entry point after rendering of the sub-window
@ -115,7 +132,7 @@ namespace OS {
* @memberof SubWindow
*/
show(): void {
this.trigger("focus");
this.trigger("focus", undefined);
this.trigger("focused", undefined);
if (this.dialog) {
this.dialog.show();
@ -129,8 +146,25 @@ namespace OS {
* @memberof SubWindow
*/
hide(): void {
return this.trigger("hide");
this.trigger("hide", undefined);
if (this.dialog) {
this.dialog.hide();
}
}
/**
* blur the sub-window
*
* @returns {void}
* @memberof SubWindow
*/
blur(): void {
this.trigger("blur", undefined);
if (this.dialog) {
this.dialog.blur();
}
}
}
SubWindow.type = ModelType.SubWindow;
@ -182,6 +216,7 @@ namespace OS {
return (this.parent.dialog = undefined);
}
}
}
/**
@ -238,6 +273,7 @@ namespace OS {
* @memberof BasicDialog
*/
init(): void {
super.init();
//this._onenter = undefined;
if (this.markup) {
if (typeof this.markup === "string") {