I using the following:
var list = [];
lin = new gui.AWindow();
Len = list.length;
lin.add(Len+1);
list[Len] = "close button";
multiple times to generate new rows of buttons in the window. I want the event handlers when the button is clicked to give its row number.
qx.Class.define("gui.AWindow",
{
extend : qx.ui.window.Window,
events :
{
"execute" : "qx.event.type.Data"
},
members :
{
add : function()
{
closeButton = new qx.ui.toolbar.Button("CLOSE");
lin.add(closeButton,{row: Pos+1, column: 0});
closeButton.addListener("execute", function(e)
{
this.debug(e.getData());
}, this);
}
},
construct : function()
{
this.base(arguments, "gui");
// hide the window buttons
this.setShowClose(false);
this.setShowMaximize(false);
this.setShowMinimize(false);
//adjust size
this.setWidth(250);
this.setHeight(300);
var layout = new qx.ui.layout.Grid(0, 0);
this.setLayout(layout);
}
});
If you use a qx.data.Array instead of using a standard JS list then you can use the indexOf method to find the index of the button in the array.
In your event handler you can use qx.event.type.Event.getTarget() method to get a reference to the widget that fired the event and pass that to the indexOf method.