mjeffw
mjeffw

Reputation: 113

Getting events in a button in a panel used as a Table cell

I'm using GWT 1.6.

I am creating a panel that contains a Button and a Label, which I then add to a FlexTable as one of its cells.

The Button is not receiving any Click events. I see that the table supports determining which Cell is clicked on, but in this case, I want the Mouse events to propagate to the various widgets inside the cell. Any idea on how to do that?

Upvotes: 0

Views: 1991

Answers (3)

Amine
Amine

Reputation: 1

You have to subclass the Button google Class and add a constructor with two additional arguments (int col, int row). e.g.

public class RuleButton extends Button {

 private int row;
 private int col;

 public RuleButton(String html, ClickListener listener, int row, int col) {
  super(html, listener);
  setRow(row);
                setCol(col);
 }
        // getters and setters for row and col attributes.
}

When adding the button, call this constructor and pass row and col indexes to it.

Upvotes: 0

Carnell
Carnell

Reputation: 749

If you know how big your table will be use a Grid instead. All of your widgets will receive there events. I have done this and created my own sortable table.

Upvotes: 0

Don Branson
Don Branson

Reputation: 13709

Yeah, I hit that, too - no widgets in the table will receive events. I ended up using code like this:


FixedWidthGrid dataTable = createDataTable();
...
dataTable.addTableListener(new TableListener() {

    public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
        storyViewer.showStory(table.getRowValue(row));
    }

});

You could probably start with something like that, then programmatically send events to your button widget to make the appearance of clicking.

Upvotes: 1

Related Questions