mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-26 07:39:04 +02:00
menu selection
This commit is contained in:
parent
f438ed6d54
commit
4a7797df6c
|
@ -10,6 +10,7 @@ import { Features } from 'util/features';
|
|||
import { MenuItem } from './menu-item';
|
||||
import { MenuOption } from './menu-option';
|
||||
import { AppSettings } from 'models/app-settings';
|
||||
import { KeyHandler } from 'comp/browser/key-handler';
|
||||
|
||||
type MenuType = 'app' | 'settings';
|
||||
|
||||
|
@ -193,6 +194,18 @@ class Menu extends Model {
|
|||
this.tagsSection.height = tagsViewHeight ?? undefined;
|
||||
});
|
||||
|
||||
KeyHandler.onKey(
|
||||
Keys.DOM_VK_UP,
|
||||
() => this.selectPrevious(),
|
||||
KeyHandler.SHORTCUT_ACTION + KeyHandler.SHORTCUT_OPT
|
||||
);
|
||||
|
||||
KeyHandler.onKey(
|
||||
Keys.DOM_VK_DOWN,
|
||||
() => this.selectNext(),
|
||||
KeyHandler.SHORTCUT_ACTION + KeyHandler.SHORTCUT_OPT
|
||||
);
|
||||
|
||||
this.setLocale();
|
||||
}
|
||||
|
||||
|
@ -231,7 +244,11 @@ class Menu extends Model {
|
|||
continue;
|
||||
}
|
||||
for (const item of section.items) {
|
||||
yield* Menu.allItemsWithin(item);
|
||||
for (const subItem of Menu.allItemsWithin(item)) {
|
||||
if (subItem.visible) {
|
||||
yield subItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,11 +272,11 @@ class Menu extends Model {
|
|||
let previousItem: MenuItem | undefined;
|
||||
|
||||
for (const item of this.visibleItems()) {
|
||||
previousItem = item;
|
||||
if (item.active && previousItem) {
|
||||
this.select({ item: previousItem });
|
||||
break;
|
||||
return;
|
||||
}
|
||||
previousItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,6 +288,7 @@ class Menu extends Model {
|
|||
activeItem = item;
|
||||
} else if (activeItem) {
|
||||
this.select({ item });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
import { Events } from 'framework/events';
|
||||
import { View } from 'framework/views/view';
|
||||
import { KeyHandler } from 'comp/browser/key-handler';
|
||||
import { Keys } from 'const/keys';
|
||||
import { Resizable } from 'framework/views/resizable';
|
||||
|
||||
class MenuView extends View {
|
||||
constructor(model, options) {
|
||||
super(model, options);
|
||||
this.listenTo(this, 'view-resize', this.viewResized);
|
||||
this.onKey(
|
||||
Keys.DOM_VK_UP,
|
||||
this.selectPreviousSection,
|
||||
KeyHandler.SHORTCUT_ACTION + KeyHandler.SHORTCUT_OPT
|
||||
);
|
||||
this.onKey(
|
||||
Keys.DOM_VK_DOWN,
|
||||
this.selectNextSection,
|
||||
KeyHandler.SHORTCUT_ACTION + KeyHandler.SHORTCUT_OPT
|
||||
);
|
||||
}
|
||||
|
||||
selectPreviousSection() {
|
||||
Events.emit('select-previous-menu-item');
|
||||
}
|
||||
|
||||
selectNextSection() {
|
||||
Events.emit('select-next-menu-item');
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(MenuView.prototype, Resizable);
|
||||
|
||||
export { MenuView };
|
Loading…
Reference in New Issue
Block a user