How to tell if XUL menupopup opens down or up?

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2010-04-23T14:19:29Z Indexed on 2010/04/25 0:13 UTC
Read the original article Hit count: 393

I have an extension that can be placed on any toolbar (like the bookmarks, menu or status bars). In general, the context menu opens downward, but when placed on the status bar and Firefox is closed to the bottom of the screen, the context menu opens upward. I'd like to try reordering the context menu based on its up or down orientation, so that the same options are always closest to the mouse.

For example, when opened downward it appears like this:

--> (mouse)
---------------
- MenuItem A  -
---------------
- MenuItem B  -
---------------
- MenuItem C  -
---------------
- .......     -
---------------

When it opens upwards its like this:

---------------
- MenuItem A  -
---------------
- MenuItem B  -
---------------
- MenuItem C  -
---------------
- .......     -
---------------
--> (mouse)

However, I'd like "MenuItem A" to appear closest to the mouse at all times, since its the most common item. I can render the items dynamically, so I really just need to find out the orientation.

© Stack Overflow or respective owner

Related posts about xul

Related posts about JavaScript