Fix shortcut bug

This commit is contained in:
lxsang 2021-03-15 21:22:24 +01:00
parent 7cd2f97b75
commit bc30261bda
6 changed files with 25 additions and 20 deletions

BIN
release/antos-1.2.0.tar.gz Normal file

Binary file not shown.

View File

@ -252,11 +252,11 @@ namespace OS {
*
* @param {string} fnk meta or modifier key e.g. `CTRL`, `ALT`, `SHIFT` or `META`
* @param {string} c a regular key
* @param {JQuery.KeyboardEventBase} e JQuery keyboard event
* @param {JQuery.KeyDownEvent} e JQuery keyboard event
* @returns {boolean} return whether the shortcut is executed
* @memberof BaseApplication
*/
shortcut(fnk: string, c: string, e: JQuery.KeyUpEvent): boolean {
shortcut(fnk: string, c: string, e: JQuery.KeyDownEvent): boolean {
if (!this.keycomb[fnk]) {
return true;
}

View File

@ -63,6 +63,7 @@ namespace OS {
*/
quit(): void {
const evt = new BaseEvent("exit", false);
this.onexit(evt);
if (!evt.prevent) {
delete this._observable;
if (this.scheme) {
@ -71,7 +72,6 @@ namespace OS {
if (this.dialog) {
return this.dialog.quit();
}
this.onexit(evt);
}
}

View File

@ -43,7 +43,7 @@ namespace OS {
*
* @memberof ShortcutType
*/
[propName: string]: GenericObject<(e: JQuery.KeyUpEvent) => void>;
[propName: string]: GenericObject<(e: JQuery.KeyDownEvent) => void>;
}
/**
@ -734,13 +734,13 @@ namespace OS {
*
* @export
* @param {string} k the hotkey e.g. `ALT-C`
* @param {(e: JQuery.MouseDownEvent) => void} f handle function
* @param {(e: JQuery.KeyPressEvent) => void} f handle function
* @param {boolean} force force to rebind the hotkey
* @returns {void}
*/
export function bindKey(
k: string,
f: (e: JQuery.KeyUpEvent) => void,
f: (e: JQuery.KeyDownEvent) => void,
force: boolean = true
): void {
const arr = k.toUpperCase().split("-");
@ -815,7 +815,6 @@ namespace OS {
if (arr.length > 1) {
tip = arr[1];
}
console.log(el);
const offset = $(el).offset();
const w = $(el).width();
const h = $(el).height();
@ -903,7 +902,7 @@ namespace OS {
$("#wrapper").append(scheme);
announcer.observable.one("sysdockloaded", () => {
$(window).on("keyup", function (event) {
$(window).on("keydown", function (event) {
const dock = $("#sysdock")[0] as tag.AppDockTag;
if (!dock) {
return;
@ -924,7 +923,7 @@ namespace OS {
if (event.shiftKey) {
fnk += "SHIFT";
}
console.log(fnk, c);
if (fnk == "") {
return;
}

View File

@ -325,7 +325,13 @@ namespace OS {
{
if(!setting.system.startup.pinned)
return;
(this.refs.pinned as GUI.tag.MenuTag).items = setting.system.startup.pinned.map((name) => {
(this.refs.pinned as GUI.tag.MenuTag).items =
setting.system.startup.pinned
.filter((el) =>{
const app = setting.system.packages[el];
return app && app.app
})
.map((name) => {
const app = setting.system.packages[name];
return {
icon: app.icon,

View File

@ -361,7 +361,7 @@ namespace OS {
this.bindKey("ALT-N", () => this.menuAction("new"));
this.bindKey("ALT-O", () => this.menuAction("open"));
this.bindKey("CTRL-ALT-F", () => this.menuAction("opendir"));
this.bindKey("ALT-F", () => this.menuAction("opendir"));
this.bindKey("CTRL-S", () => this.menuAction("save"));
this.bindKey("ALT-W", () => this.menuAction("saveas"));
@ -792,7 +792,7 @@ namespace OS {
{
text: __("Open Folder"),
dataid: "opendir",
shortcut: "C-A-F",
shortcut: "A-F",
},
{ text: __("Save"), dataid: "save", shortcut: "C-S" },
{