Commit e635293c authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Merge branch 'dd_lightbar_menu_onItemNav_startup' into 'master'

DDLightbarMenu OnItemNav on initial display

See merge request !168
parents c4fc80ab f70fc096
......@@ -291,7 +291,12 @@ lbMenu.exitOnItemSelect = false;
OnItemNav is a function that is called when the user navigates to a new item (i.e., via
the up or down arrow, PageUp, PageDown, Home, End, etc.). Its parameters are the old
item index and the new item index.
this.OnItemNav = function(pOldItemIdx, pNewItemIdx) { }
lbMenu.OnItemNav = function(pOldItemIdx, pNewItemIdx) { }
To have the menu object call OnItemNav() when it is first displayed to get the user's
choice, set the callOnItemNavOnStartup property to true:
lbMenu.callOnItemNavOnStartup = true;
By default, it is false.
The 'key down' behavior can be called explicitly, if needed, by calling the DoKeyDown() function.
It takes 2 parameters: An object of selected item indexes (as passed to GetVal()) and, optionally,
......@@ -474,6 +479,10 @@ function DDLightbarMenu(pX, pY, pWidth, pHeight)
this.inputTimeoutMS = 300000; // Input timeout in ms
this.mouseEnabled = false;
// Whether or not to call OnItemNav() when the menu is first displayed
// to get the user's choice
this.callOnItemNavOnStartup = false;
// Member functions
this.Add = DDLightbarMenu_Add;
this.Remove = DDLightbarMenu_Remove;
......@@ -1389,6 +1398,9 @@ function DDLightbarMenu_GetVal(pDraw, pSelectedItemIndexes)
this.DisplayInitialScrollbar(this.scrollbarInfo.solidBlockLastStartRow);
}
if (this.callOnItemNavOnStartup && typeof(this.OnItemNav) === "function")
this.OnItemNav(0, this.selectedItemIdx);
// User input loop
var userChoices = null; // For multi-select mode
var selectedItemIndexes = { }; // For multi-select mode
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment