I have a TableEx with row selection enabled. Each row contains a label and a button.
Under Firefox, the button generates a row selection event instead of a button event.
However under IE, clicking on the button generates a button event. This is the behaviour I'm after.
The echo2 Table also generates action events.
Here is some code to reproduce the problem.
It displays two tables, each with a single row containing a label and a button.
The first table is an echo2 Table, the second an EPNG TableEx instance.
Clicking on the label in both should produce a popup saying "Row selected".
Clicking on the button should produce a popup saying "Button pressed"
public class TableExTest extends ContentPane {
public TableExTest() {
Column column = new Column();
column.setCellSpacing(new Extent(50));
column.add(init(new Table()));
column.add(init(new TableEx()));
add(column);
}
private Component init(Table table) {
DefaultTableModel model = new DefaultTableModel(2, 0);
TableCellRenderer render = new TableCellRenderer() {
public Component getTableCellRendererComponent(Table table,
Object value,
int column,
int row) {
if (value instanceof Component) {
return (Component) value;
}
return null;
}
};
table.setDefaultRenderer(Object.class, render);
table.setSelectionEnabled(true);
table.setRolloverEnabled(true);
table.setRolloverBackground(Color.BLUE);
table.setBorder(new Border(1, Color.BLACK, Border.STYLE_SOLID));
table.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Popup("Row selected");
}
});
Button button = new Button("a button");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Popup("Button pressed");
}
});
model.addRow(new Object[]{new Label("a label"), button});
table.setModel(model);
Column column = new Column();
column.setCellSpacing(new Extent(5));
column.add(new Label(table.getClass().getName()));
column.add(table);
return column;
}
class Popup extends WindowPane {
public Popup(String title) {
setTitle(title);
setModal(true);
Window root = ApplicationInstance.getActive().getDefaultWindow();
root.getContent().add(this);
}
}
}
This occurs using both the released echopointng echopointng-2.1.0rc5.jar and CVS HEAD
hi,
I encountered the same problem, is there already a solution/workaround available?
greetings gandulf
EDIT: After setting useCapture to false in the addEventListener method of the table (in my case EPNG.TableEx) for the click event the problem was solved.
Can you please explain where
Can you please explain where in code did you set the useCapture to false? Thanks!
As of November 2008
...this problem still exists
ok here is how i did it, but
ok here is how i did it, but all chganges come without warranty and i'm not sure if i broke some other stuff ;-)
first i added an additoinal parameter to the addHandler and removeHandler function in ep.js around line 1000
EP.Event.addHandler = function(eventType, elem, obj, useCapture) { if (! elem) { throw "EP.Event.addHandler : null element provided : " + eventType; } if (useCapture == undefined) { useCapture=true; } eventType = EP.Event.transmogifryEventType(eventType); var f = EP.Event.dispatchEventHandler; if (elem.addEventListener) { // MOZ elem.addEventListener(eventType, f, useCapture); } else if (elem.attachEvent) { // IE elem.attachEvent("on" + eventType, f); } }; /** * This removes an event handler that was previously added via * EP.Event.addHandler. * * PATCH for IEI-1024 added useCapture parameter */ EP.Event.removeHandler = function(eventType, elem, useCapture) { if (! elem) { return; // nothing to detach } if (useCapture == undefined) { useCapture=true; } eventType = EP.Event.transmogifryEventType(eventType); var f = EP.Event.dispatchEventHandler; if (elem.removeEventListener) { // MOZ elem.removeEventListener(eventType,f,useCapture); } else if (elem.detachEvent) { // IE elem.detachEvent("on" + eventType,f); } };then i replaced the call to removeHandler in tableex.js (around line 243)
if (this.selectionEnabled) { EP.Event.removeHandler('click',trElement,false); // PATCH for BUG (the ",false" was added.) }and the same for adding the Handler around line 352 in tableex.js
if (this.selectionEnabled) { EP.Event.addHandler('click',trElement,this,false); // PATCH for IEI-1024 }that's it. hope it will help you.