Don't close PopupMenu when MenuItem clicked

182 views
Skip to first unread message

Kevin Lynagh

unread,
Jun 7, 2012, 8:18:20 PM6/7/12
to Closure Library Discuss
I'm trying to put a custom control widget inside of a PopupMenu.
Initializing a MenuItem with the widget as the content works great,
but clicking inside of the widget closes the PopupMenu.
I've tried adding event listeners to both the popup menu and the menu
item to see what they are emitting, but thus far calling
stopPropogation on all of those events still does not prevent the
popup menu from closing.

I saw this earlier thread on a similar topic; that approach seemed to
work then, so I'm not sure what is different in my situation.

http://groups.google.com/group/closure-library-discuss/browse_thread/thread/16b0886738e90294/727977cf6c52b8d6?lnk=gst&q=menuitem#727977cf6c52b8d6

Rhys Brett-Bowen

unread,
Jun 11, 2012, 5:29:19 PM6/11/12
to closure-lib...@googlegroups.com
I'm sure I did something like this before but not knowing your code the best advice I can give is to open up your web inspector and set a breakpoint inside the popupmenu.js file in the good.ui.popupmenu.prototype.hide function. Then you can just walk back through your stack trace and see where that is firing. If it's coming from your menuItem then you may consider overriding that method that is calling it.

Kevin Lynagh

unread,
Jun 13, 2012, 12:01:15 AM6/13/12
to Closure Library Discuss
Rhys,

That's such an obvious, great idea!
I did that and discovered that all I needed to do was subclass the
goog.ui.PopupMenu and override the default onBlur to be a no-op
instead of hiding.

Thanks!
> >http://groups.google.com/group/closure-library-discuss/browse_thread/...
Reply all
Reply to author
Forward
0 new messages