This post was published back in 2008. It may not function as originally intended or may be missing images.
Replace Standard Menupop in XUL
I came across a time I needed to open a different element then a standard popup menu when clicking the dropdown selector on a toolbar button. I wanted to open a panel instead. To open a different element and hide the popup you can do something similar to this:
Where I learned it: While working on the Read It Later Firefox Extension