Skip to content
Snippets Groups Projects
Commit f70fc096 authored by Eric Oulashin's avatar Eric Oulashin
Browse files

DDLightbarMenu OnItemNav on initial display

DDLightbarMenu can now optionally call its OnItemNav function when
it's first displayed.  By default this behavior is disabled, but it
can be enabled by setting the (new) callOnItemNavOnStartup property
to true.
parent c4fc80ab
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!168DDLightbarMenu OnItemNav on initial display
Pipeline #2948 passed
...@@ -291,7 +291,12 @@ lbMenu.exitOnItemSelect = false; ...@@ -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 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 the up or down arrow, PageUp, PageDown, Home, End, etc.). Its parameters are the old
item index and the new item index. 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. 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, 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) ...@@ -474,6 +479,10 @@ function DDLightbarMenu(pX, pY, pWidth, pHeight)
this.inputTimeoutMS = 300000; // Input timeout in ms this.inputTimeoutMS = 300000; // Input timeout in ms
this.mouseEnabled = false; 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 // Member functions
this.Add = DDLightbarMenu_Add; this.Add = DDLightbarMenu_Add;
this.Remove = DDLightbarMenu_Remove; this.Remove = DDLightbarMenu_Remove;
...@@ -1389,6 +1398,9 @@ function DDLightbarMenu_GetVal(pDraw, pSelectedItemIndexes) ...@@ -1389,6 +1398,9 @@ function DDLightbarMenu_GetVal(pDraw, pSelectedItemIndexes)
this.DisplayInitialScrollbar(this.scrollbarInfo.solidBlockLastStartRow); this.DisplayInitialScrollbar(this.scrollbarInfo.solidBlockLastStartRow);
} }
if (this.callOnItemNavOnStartup && typeof(this.OnItemNav) === "function")
this.OnItemNav(0, this.selectedItemIdx);
// User input loop // User input loop
var userChoices = null; // For multi-select mode var userChoices = null; // For multi-select mode
var selectedItemIndexes = { }; // For multi-select mode var selectedItemIndexes = { }; // For multi-select mode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment