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} fnk meta or modifier key e.g. `CTRL`, `ALT`, `SHIFT` or `META`
* @param {string} c a regular key * @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 * @returns {boolean} return whether the shortcut is executed
* @memberof BaseApplication * @memberof BaseApplication
*/ */
shortcut(fnk: string, c: string, e: JQuery.KeyUpEvent): boolean { shortcut(fnk: string, c: string, e: JQuery.KeyDownEvent): boolean {
if (!this.keycomb[fnk]) { if (!this.keycomb[fnk]) {
return true; return true;
} }

View File

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

View File

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

View File

@ -325,15 +325,21 @@ namespace OS {
{ {
if(!setting.system.startup.pinned) if(!setting.system.startup.pinned)
return; return;
(this.refs.pinned as GUI.tag.MenuTag).items = setting.system.startup.pinned.map((name) => { (this.refs.pinned as GUI.tag.MenuTag).items =
const app = setting.system.packages[name]; setting.system.startup.pinned
return { .filter((el) =>{
icon: app.icon, const app = setting.system.packages[el];
iconclass: app.iconclass, return app && app.app
app: app.app, })
tooltip: `cb:${app.name}` .map((name) => {
}; const app = setting.system.packages[name];
}); return {
icon: app.icon,
iconclass: app.iconclass,
app: app.app,
tooltip: `cb:${app.name}`
};
});
} }
/** /**

View File

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