Skip to Content
0
Sep 22, 2012 at 06:51 PM

Menu Button press event at the wrong moment

101 Views

Hello again.

In version 1.6.3 we have the new Menu Button. It has two events, press and ItemSelected.

The problem is that both events are raised when the item is selected. One would have wished the press event to be raised when the button is pressed as with a normal button. This effectively rules out the possibility of dynamic item creation.

Code as from documentation with press event handler added:

var oMenuButton = new sap.ui.commons.MenuButton({text: "Hello"});

var oMenu1 = new sap.ui.commons.Menu("menu1");

var oMenuItem1 = new sap.ui.commons.MenuItem("item1-1",{text: "New"});

oMenu1.addItem(oMenuItem1);

oMenuButton.setMenu(oMenu1);

oMenuButton.attachPress(function(oEvent){

alert("On item selected-Should be when button pressed");

});

oMenuButton.attachItemSelected(function (oEvent){

alert("On item selected");

});

oMenuButton.placeAt("content");

Cheers

Martin