Sorry, the useful function probably ought to be something like the
following. I'm sure Hrvoje can sanitize this ;-)
-Barry
-------------------- snip snip --------------------
(defun imenu-popup-menu (event)
"Wrapper for mouse button bindings for imenu."
(interactive "e")
(let* ((answer (imenu--mouse-menu (imenu--make-index-alist) event))
(name (car answer))
(position (cdr answer)))
(if (< 0 position)
(imenu-default-goto-function name position)
(imenu--cleanup)
(setq imenu--index-alist nil))))