Fixed active first item on non-hint menus
diff --git a/dev/demo/menudemo.js b/dev/demo/menudemo.js
index 055963b..1df0f55 100644
--- a/dev/demo/menudemo.js
+++ b/dev/demo/menudemo.js
@@ -49,9 +49,11 @@
var OwnMenu = {
create : function (params) {
- return Object.create(menuClass)
+ var obj = Object.create(menuClass)
.upgradeTo(this)
._init(OwnMenuItemClass, OwnPrefixClass, params);
+ obj._firstActive = true;
+ return obj;
}
};
diff --git a/dev/js/src/hint/menu.js b/dev/js/src/hint/menu.js
index bf965d7..4704bd2 100644
--- a/dev/js/src/hint/menu.js
+++ b/dev/js/src/hint/menu.js
@@ -15,6 +15,9 @@
obj._element.classList.add('hint');
obj._hint = hint;
+ // Make the top item always active
+ obj._firstActive = true;
+
// This is only domspecific
obj.element().addEventListener('blur', function (e) {
this.menu.hide();
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index cc42855..4b95ae9 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -4,6 +4,7 @@
* @author Nils Diewald
*/
/*
+ * TODO: First item shouldn't be automatically highlighted!
* TODO: space is not a valid prefix!
* TODO: Prefix should be case sensitive!
*/
@@ -215,6 +216,7 @@
this._limit = menuLimit;
this._position = 0; // position in the active list
this._active = -1; // active item in the item list
+ this._firstActive = false; // Show the first item active always?
this._reset();
return this;
},
@@ -285,7 +287,9 @@
// Set the first element to active
// Todo: Or the last element chosen
- this.liveItem(0).active(true);
+ if (this._firstActive)
+ this.liveItem(0).active(true);
+
this._prefix.active(false);
this._active = this._list[0];