Using the following code, I create a popupmenu, add it to the DOM, and
populate it. Upon first appearance, the first element is visible.
If I scroll the menu items down, then close the popup, upon
the next appearance, it’s positioned where it was closed,
even though it’s been re-built.
How do I always set the menu item list so that the first
element is visible?
code:
var popup = document.getElementById(“edgewise-popMenu”) ; // already exist?..
if (popup) { // yes…
while (popup.firstChild) { // clear old items…
popup.removeChild(popup.firstChild) ;
}
}
else { // new…
popup = document.createElement(“menupopup”) ;
popup.setAttribute(“id”, “edgewise-popMenu”) ;
var popupSet = document.getElementById("mainPopupSet") ; // add to DOM...
popupSet.appendChild(popup) ;
}
// add all EW Actions to menu…
for (var i = 0; i < EdgeWiseOV.actions.length; i++) { // for each EW Action…
var item = document.createElement(‘menuitem’) ;
item.setAttribute(‘label’, EdgeWiseOV.actions[i].visual) ;
item.setAttribute(‘value’, EdgeWiseOV.actions[i].code) ;
item.setAttribute(‘tooltiptext’, EdgeWiseOV.actions[i].tip) ;
item.addEventListener(“command”, function (itemEvt) { // make it clickable…
EdgeWiseOV.doClickRun(itemEvt.originalTarget.getAttribute(“value”)) ;
},
false ) ;
popup.appendChild(item) ;
}
popup.openPopupAtScreen( 1, 29, false) ; // show to user
code end
Thanks to anyone…
Paul