Commit 71329289 authored by Dave Cooper's avatar Dave Cooper
Browse files

added optional popup menu

parent d314e4d5
......@@ -89,6 +89,8 @@ function hideMenus(event, force=null)
(! (li == obj))
li.classList.remove('visible');
}
// if (typeof inactivateMenu === 'function') { inactivateMenu(); }
}
setTimeout(hideMenus, 10);
......
......@@ -67,35 +67,9 @@
:computed-slots
(
;;
;; For testing
;;
#+nil
(menu-html (with-cl-who-string ()
(:style ".view-menu
{
display: none;
position: absolute;
z-index: 10;
}
.view-menu--active{
display: block;
}
")
((:nav :class "menu context-menu"
:id "menu")
((:ul :id "menu" :class "menu")
((:li :onclick (the (gdl-ajax-call :function-key :set-view! :arguments (list :top)))) "top")
(:li "left")))))
(empty? (not (or (the display-list-object-roots)
(the display-list-objects))))
#+nil
(zoom-factor-renderer (case (the root-object-type)
('gdl-user::house 0.016)
(otherwise 1)))
(recompute? nil :settable)
......@@ -119,6 +93,110 @@ z-index: 10;
;;(operations-list nil :settable)
(popup-menu-text
(case (the image-format-selector value)
((:x3dom :svg)
(format nil
"
console.log ('running popup-menu-text...');
function getPosition(e) {
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY) {
posx = e.clientX + document.body.scrollLeft +
document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop +
document.documentElement.scrollTop;
}
return {
x: posx,
y: posy
}
}
var menuPosition;
var menuPositionX;
var menuPositionY;
var can = document.getElementById('x3dom-x3dom-1-canvas') || document.getElementById('svg-1');
var menuState = 0;
var active = 'popup-menu-visible';
var vmenu = document.getElementById('~a');
function positionMenu(e) {
menuPosition = getPosition(e);
menuPositionX = menuPosition.x + 'px';
menuPositionY = menuPosition.y + 'px';
console.log ('position-x: ' + menuPosition.x + 'position-y: ' + menuPosition.y);
console.log ('vmenu is: ' + vmenu);
vmenu.style.left = menuPositionX;
vmenu.style.top = menuPositionY;
}
if (can)
{
can.addEventListener('contextmenu', function(e){
e.preventDefault();
e.stopPropagation();
//window.scrollTo(0,0);
if (menuState == 0) {
menuState = 1;
vmenu.classList.add(active);
makeMenuBarHoverable(e);
positionMenu(e);
vmenu.querySelector('li').classList.add('visible');
}
else
{
inactivateMenu();
// menuState = 0;
// vmenu.classList.remove(active);
}
console.log('menuState: ' + menuState);
})
}
function inactivateMenu ()
{
menuState = 0;
vmenu.classList.remove(active);
}
inactivateMenu ();
document.addEventListener('click', inactivateMenu);
console.log ('Done running popup-menu-text...');
"
(the menu dom-id)))))
(viewport-js-text
(case (the image-format-selector value)
(:x3dom
......
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