This content has been marked as final.
Show 3 replies
-
1. Re: Position of the context menu or the clicked menu item
marantis Jul 13, 2014 6:10 AM (in response to marantis)... or alternative ...
how can i get the mouse position when the menu item was clicked?
-
2. Re: Re: Position of the context menu or the clicked menu item
michpetrov Jul 14, 2014 4:20 AM (in response to marantis)You can capture the mouse click event:
<rich:menuItem … onclick="captureEvent(event)"/> <h:outputScript> captureEvent = function (e) { mouseX = e.pageX; mouseY = e.pageY; … }; </h:outputScript>
The parameter in the onclick has to be named "event".
-
3. Re: Position of the context menu or the clicked menu item
marantis Jul 14, 2014 7:12 PM (in response to michpetrov)Big thx Petrov!^^
nice tip for the 2nd question.
but ...
for the 1st question the answer should be something like this ...
<script type="text/javascript"> //<![CDATA[ function savePosition(mnuItem) { var x = mnuItem.element.offset().left; var y = mnuItem.element.offset().top; ... } //]]> </script>
<h:form id="idForm"> <rich:tree id="idTree" ...> </rich:tree> <rich:contextMenu id="idContextMenu" target="idTree" mode="ajax"> <rich:menuItem id="idContextMenuItem1" mode="ajax" onbeforedomupdate="savePosition(#{rich:component('idContextMenuItem1')})" oncomplete="#{rich:component('popup')}.show()"/> ... </rich:contextMenu> </h:form>
but it doesn't work cause LEFT ist ALWAYS just ZERO! (only the value of TOP is ok)
Is this a BUG?!