开发者

How to tell if XUL menupopup opens down or up?

开发者 https://www.devze.com 2022-12-28 11:01 出处:网络
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

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 r开发者_如何学Pythoneordering 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.


When developing a FF extension, the MDC docs are invaluable. Be prepared to spend a lot of time there.

There is also a lot of really great help on irc.mozilla.net in various channels. Most pages on MDC will tell you the relevant channel for the page you are looking at. Look for "discuss in irc" in the upper right-hand corner.

Some possibly relevant docs for you:

https://developer.mozilla.org/en/XUL:menupopup#a-popup.position

https://developer.mozilla.org/en/XUL:menuitem

https://developer.mozilla.org/en/XUL:Attribute:insertbefore

0

精彩评论

暂无评论...
验证码 换一张
取 消