Mouse Position Troubles, Again
Posted: Tue Jan 21, 2014 12:52 pm
I had a previous thread where I was having trouble positioning a pop-up menu based on the current mouse position:
http://www.profoundlogic.com/forum/view ... =53&t=1599
That issue was resolved by combining information from the getMouseX() and getMouseY() API's with some pui.runtimeContainer properties. However, keeping the same code, I'm finding that though it continues to work for the main page, it doesn't work for a pop-up window which is displayed over that page.
I have this function for extracting everything I would want to know about the dimensions and position offsets of the browser page, the browser client area, the PUI runtime container, and the mouse position.
I've included two snapshots -- where the first shows the pop-up menu on the main page:
...and the second shows the pop-up menu on the pop-up window over that page.
In both cases, I left-clicked on the icon shown in the first grid row and I call the following function from the onclick event of that icon.
wob.showOptionsMenu("mnuSelect", event);
Now, as I said, this is all working perfectly when operating from just the main PUI page. How do I have to adjust any of this code to make it also work when operating from a PUI pop-up window which is displayed over that main PUI page?
http://www.profoundlogic.com/forum/view ... =53&t=1599
That issue was resolved by combining information from the getMouseX() and getMouseY() API's with some pui.runtimeContainer properties. However, keeping the same code, I'm finding that though it continues to work for the main page, it doesn't work for a pop-up window which is displayed over that page.
I have this function for extracting everything I would want to know about the dimensions and position offsets of the browser page, the browser client area, the PUI runtime container, and the mouse position.
Code: Select all
/* ================================================================================
getContainerOffsets() dynamically removes the designated grid column and adjusts
the width of a remaining displayed grid column to include
the width of the column that was removed. This is so that
the overall width of the grid remains the same. Conversely,
if you do NOT want the width of the removed column added
back in to the overall grid width, then just specify -1 for
the adjustment column.
*/
wob.getContainerOffsets = function(event)
{
var offsets = wob.browserPageOffsets(); // get scrolled offset of page
offsets.client = wob.browserClientArea(); // get client area of page
if (event)
{
offsets.mouseLeft = offsets.left + getMouseX(event); // set mouse coordinates
offsets.mouseTop = offsets.top + getMouseY(event);
offsets.mouseLeft -= pui.runtimeContainer.offsetLeft; // adjust for Profound's outer container
offsets.mouseTop -= pui.runtimeContainer.offsetTop;
}
offsets.left += pui.runtimeContainer.offsetLeft; // adjust for Profound's outer container
offsets.top += pui.runtimeContainer.offsetTop;
offsets.width = pui.runtimeContainer.clientWidth;
if (pui.runtimeContainer.clientHeight > 0)
{
offsets.height = pui.runtimeContainer.clientHeight - pui.runtimeContainer.offsetTop;
}
else
{
offsets.height -= pui.runtimeContainer.offsetTop;
}
return offsets; // return offsets to caller
}
...and the second shows the pop-up menu on the pop-up window over that page.
In both cases, I left-clicked on the icon shown in the first grid row and I call the following function from the onclick event of that icon.
wob.showOptionsMenu("mnuSelect", event);
Code: Select all
/* ================================================================================
showOptionsMenu() positions an invisible menu widget at the current mouse
position and then makes the menu visible.
*/
wob.showOptionsMenu = function(menuId, event)
{
var offsets = wob.getContainerOffsets(event); // get page and mouse offsets
applyProperty(menuId, "left", (offsets.mouseLeft - 5) + "px"); // position the menu
applyProperty(menuId, "top", (offsets.mouseTop - 5) + "px");
applyProperty(menuId, "z index", 200); // put menu on top of everything
applyProperty(menuId, "visibility", "visible"); // make menu visible
}