Re: MenuButton take it open

79 views
Skip to first unread message

Peter Pallos

unread,
Jan 31, 2012, 7:13:29 AM1/31/12
to closure-lib...@googlegroups.com
goog.events.listen(menuitem, goog.ui.Component.EventType.ACTION, goog.events.Event.stopPropagation) should work.

Peter

On Tue, Jan 31, 2012 at 1:05 PM, Markus <m.gad...@zerodo.it> wrote:
Hello everyone,
i'm using MenuButton.
Inside a menu button i put a FilteredMenu,
but when i click inside the menu component it closed itself.
I'm trying to use setOpen(true) on the button,
but after the click, the menu is closed.

There is a way to force the menu button to remains open when i click inside?

thx

Markus

unread,
Jan 31, 2012, 9:42:55 AM1/31/12
to closure-lib...@googlegroups.com
If i apply this command to single item it not works...

Peter Pallos

unread,
Jan 31, 2012, 9:56:06 AM1/31/12
to closure-lib...@googlegroups.com
I don't have enough information to help more.

Markus

unread,
Jan 31, 2012, 10:01:54 AM1/31/12
to closure-lib...@googlegroups.com
I do this:

First declare the menu
this.menu1 = new goog.ui.FilteredMenu();
this.menu1.setFilterLabel('Create / search');
this.menu1.setAllowMultiple(true);
this.menu1.addItem(new goog.ui.CheckBoxMenuItem("one"));
this.menu1.addItem(new goog.ui.CheckBoxMenuItem("two"));
after declare the menu button
this.b1 = new goog.ui.MenuButton('File',this. menu1,
new goog.ui.Css3MenuButtonRenderer());

this.b1.setId('FileButton');
this.b1.render(goog.dom.getElement('btnMenu'));
   
The problem is that when i click inside menuitem, the menu close its self

Peter Pallos

unread,
Jan 31, 2012, 10:15:02 AM1/31/12
to closure-lib...@googlegroups.com
After short debugging I found out that goog.ui.MenuButton.prototype.setOpen is also called by the mouseup handler.
goog.events.listen(item.getElement(), goog.events.EventType.MOUSEUP, goog.events.Event.stopPropagation);
finally prevented the menu item from being closed. I don't know if there is a cleaner solution.

Peter

Markus

unread,
Jan 31, 2012, 10:38:02 AM1/31/12
to closure-lib...@googlegroups.com
Thx ;-)
Reply all
Reply to author
Forward
0 new messages