Skip to content

Commit

Permalink
Merge pull request #2036 from cb1kenobi/timob-8352
Browse files Browse the repository at this point in the history
[TIMOB-8352] Fixed tableview clicking below rows.
  • Loading branch information
nebrius committed Apr 19, 2012
2 parents bfb53fc + 2793f1d commit a0b354b
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions mobileweb/titanium/Ti/UI/TableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/style", "Ti/_/lang","Ti/UI/MobileWeb
var setStyle = style.set,
is = require.is,
isDef = lang.isDef,
refreshSections = function() {
this._refreshSections();
};

regexpClickTap = /^(click|singletap)$/;

return declare("Ti.UI.TableView", View, {

constructor: function(args) {
Expand Down Expand Up @@ -162,34 +160,37 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/style", "Ti/_/lang","Ti/UI/MobileWeb
},

_handleTouchEvent: function(type, e) {
if (type === "click" || type === "singletap") {
if (this._tableViewRowClicked && this._tableViewSectionClicked) {
e.row = this._tableViewRowClicked;
e.rowData = this._tableViewRowClicked;
var index = 0,
sections = this._sections.children;
for(var i = 0; i < sections.length; i+= 2) {
var localIndex = sections[i]._rows.children.indexOf(this._tableViewRowClicked);
var i = 0,
index = 0,
localIndex,
sections = this._sections.children,
row = this._tableViewRowClicked,
section = this._tableViewSectionClicked;

if (row && section) {
if (regexpClickTap.test(type)) {
for (; i < sections.length; i += 2) {
localIndex = sections[i]._rows.children.indexOf(row);
if (localIndex !== -1) {
index += Math.floor(localIndex / 2);
break;
} else {
index += sections[i].rowCount;
}
}
e.row = e.rowData = row;
e.index = index;
e.section = this._tableViewSectionClicked;
e.section = section;
e.searchMode = false;
View.prototype._handleTouchEvent.apply(this,arguments); // This intentionally squelches the event if a row was not click
}
} else {
View.prototype._handleTouchEvent.apply(this,arguments);

View.prototype._handleTouchEvent.apply(this, arguments);

this._tableViewRowClicked = null;
this._tableViewSectionClicked = null;
}
},

_tableViewRowClicked: null,
_tableViewSectionClicked: null,


_createSeparator: function() {
var separator = UI.createView({
height: 1,
Expand Down Expand Up @@ -378,21 +379,21 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/style", "Ti/_/lang","Ti/UI/MobileWeb
}
},
maxRowHeight: {
post: refreshSections
post: "_refreshSections"
},
minRowHeight: {
post: refreshSections
post: "_refreshSections"
},
rowHeight: {
post: refreshSections,
post: "_refreshSections",
value: "50px"
},
separatorColor: {
post: refreshSections,
post: "_refreshSections",
value: "lightGrey"
},
separatorStyle: {
post: refreshSections,
post: "_refreshSections",
value: TableViewSeparatorStyle.SINGLE_LINE
}
}
Expand Down

0 comments on commit a0b354b

Please sign in to comment.