added keyboard navigation for menus that scroll

upd4.2
Jens Mönig 2018-01-04 17:46:40 +01:00
rodzic 922dcc279e
commit 8122e15050
2 zmienionych plików z 29 dodań i 12 usunięć

Wyświetl plik

@ -3829,6 +3829,7 @@ Fixes:
180104 180104
------ ------
* Morphic: scroll menus if they are taller than the world * Morphic: scroll menus if they are taller than the world
* Morphic: added keyboard navigation for menus that scroll

Wyświetl plik

@ -7918,21 +7918,31 @@ MenuMorph.prototype.processKeyPress = function (event) {
}; };
MenuMorph.prototype.selectFirst = function () { MenuMorph.prototype.selectFirst = function () {
var i; var scroller, items, i;
for (i = 0; i < this.children.length; i += 1) {
if (this.children[i] instanceof MenuItemMorph) { scroller = detect(this.children, function (morph) {
this.select(this.children[i]); return morph instanceof ScrollFrameMorph;
});
items = scroller ? scroller.contents.children : this.children;
for (i = 0; i < items.length; i += 1) {
if (items[i] instanceof MenuItemMorph) {
this.select(items[i]);
return; return;
} }
} }
}; };
MenuMorph.prototype.selectUp = function () { MenuMorph.prototype.selectUp = function () {
var triggers, idx; var scroller, triggers, idx;
triggers = this.children.filter(function (each) { scroller = detect(this.children, function (morph) {
return each instanceof MenuItemMorph; return morph instanceof ScrollFrameMorph;
}); });
triggers = (scroller ? scroller.contents.children : this.children).filter(
function (each) {
return each instanceof MenuItemMorph;
}
);
if (!this.selection) { if (!this.selection) {
if (triggers.length) { if (triggers.length) {
this.select(triggers[0]); this.select(triggers[0]);
@ -7947,11 +7957,16 @@ MenuMorph.prototype.selectUp = function () {
}; };
MenuMorph.prototype.selectDown = function () { MenuMorph.prototype.selectDown = function () {
var triggers, idx; var scroller, triggers, idx;
triggers = this.children.filter(function (each) { scroller = detect(this.children, function (morph) {
return each instanceof MenuItemMorph; return morph instanceof ScrollFrameMorph;
}); });
triggers = (scroller ? scroller.contents.children : this.children).filter(
function (each) {
return each instanceof MenuItemMorph;
}
);
if (!this.selection) { if (!this.selection) {
if (triggers.length) { if (triggers.length) {
this.select(triggers[0]); this.select(triggers[0]);
@ -7988,6 +8003,7 @@ MenuMorph.prototype.select = function (aMenuItem) {
this.unselectAllItems(); this.unselectAllItems();
aMenuItem.image = aMenuItem.highlightImage; aMenuItem.image = aMenuItem.highlightImage;
aMenuItem.changed(); aMenuItem.changed();
aMenuItem.scrollIntoView();
this.selection = aMenuItem; this.selection = aMenuItem;
}; };