Skip to content

Commit

Permalink
TIMOB-13055: Direct tableview events to tableview row
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Yeung committed Mar 29, 2013
1 parent 0947a34 commit 830727f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Expand Up @@ -157,11 +157,12 @@ public boolean fireEvent(String eventName, Object data, boolean bubbles)
if (dataCopy.containsKey(TiC.PROPERTY_X) && dataCopy.containsKey(TiC.PROPERTY_Y)) {
double x = dataCopy.getDouble(TiC.PROPERTY_X);
double y = dataCopy.getDouble(TiC.PROPERTY_Y);
Object source = dataCopy.get(TiC.PROPERTY_SOURCE);
int index = getTableView().getTableView().getIndexFromXY(x, y);
if (index != -1) {
if (index != -1 && source == this) {
Item item = getTableView().getTableView().getItemAtPosition(index);
TableViewRowProxy.fillClickEvent(dataCopy, getTableView().getModel(), item);
data = dataCopy;
dataCopy.put(TiC.PROPERTY_SOURCE, item.proxy);
return item.proxy.fireEvent(eventName, dataCopy, bubbles);
}
}
}
Expand Down
Expand Up @@ -202,18 +202,16 @@ public static void fillClickEvent(HashMap<String, Object> data, TableViewModel m
@Override
public boolean fireEvent(String eventName, Object data, boolean bubbles)
{
if (eventName.equals(TiC.EVENT_CLICK) || eventName.equals(TiC.EVENT_LONGCLICK)) {
// Inject row click data for events coming from row children.
TableViewProxy table = getTable();
Item item = tableViewItem.getRowData();
if (table != null && item != null && data instanceof HashMap) {
// The data object may already be in use by the runtime thread
// due to a child view's event fire. Create a copy to be thread safe.
@SuppressWarnings("unchecked")
KrollDict dataCopy = new KrollDict((HashMap<String, Object>) data);
fillClickEvent(dataCopy, table.getTableView().getModel(), item);
data = dataCopy;
}
// Inject row click data for events coming from row children.
TableViewProxy table = getTable();
Item item = tableViewItem.getRowData();
if (table != null && item != null && data instanceof HashMap) {
// The data object may already be in use by the runtime thread
// due to a child view's event fire. Create a copy to be thread safe.
@SuppressWarnings("unchecked")
KrollDict dataCopy = new KrollDict((HashMap<String, Object>) data);
fillClickEvent(dataCopy, table.getTableView().getModel(), item);
data = dataCopy;
}
return super.fireEvent(eventName, data, bubbles);
}
Expand Down

0 comments on commit 830727f

Please sign in to comment.