Skip to content

Commit

Permalink
Merge pull request #2512 from bryan-m-hughes/timob-9894
Browse files Browse the repository at this point in the history
[TIMOB-9894] LongPress support in table view.
  • Loading branch information
cb1kenobi committed Jul 6, 2012
2 parents 24b49ef + f6253e6 commit 0292ebd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ events:
A `longpress` and a `longclick` can occur together.
In contrast to a `longclick`, this event returns the `x` and `y` coordinates of the touch.
platforms: [android, iphone, ipad]
platforms: [android, iphone, ipad, mobileweb]
properties:
- name: x
summary: X coordinate of the event from the `source` view's coordinate system.
Expand Down
2 changes: 1 addition & 1 deletion mobileweb/titanium/Ti/UI/TableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",
sections = this._sections._children,
row = this._tableViewRowClicked,
section = this._tableViewSectionClicked;
if (type === "click" || type === "singletap") {
if (type === "click" || type === "singletap" || type === "longpress") {
if (row && section) {

for (; i < sections.length; i += 2) {
Expand Down
11 changes: 7 additions & 4 deletions mobileweb/titanium/Ti/UI/TableViewRow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
define(["Ti/_/declare", "Ti/_/lang", "Ti/UI/View", "Ti/_/dom", "Ti/_/css", "Ti/_/style", "Ti/UI", "Ti/_/Layouts/ConstrainingHorizontal"],
function(declare, lang, View, dom, css, style, UI, ConstrainingHorizontal) {

var setStyle = style.set,
var on = require.on,
emptyfn = function(){},
setStyle = style.set,
isDef = lang.isDef,
imagePrefix = "themes/" + require.config.ti.theme + "/UI/TableViewRow/",
checkImage = imagePrefix + "check.png",
Expand Down Expand Up @@ -45,8 +47,9 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/UI/View", "Ti/_/dom", "Ti/_/css", "Ti/_
height: UI.SIZE
}));

// Force single tap to be processed.
this.addEventListener("singletap");
// Force single tap and long press to be enabled.
on(this, "singletap", emptyfn);
on(this, "longpress", emptyfn);
},

_defaultWidth: UI.INHERIT,
Expand All @@ -58,7 +61,7 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/UI/View", "Ti/_/dom", "Ti/_/css", "Ti/_
_tableViewSection: null,

_handleTouchEvent: function(type, e) {
if (type === "click" || type === "singletap") {
if (type === "click" || type === "singletap" || type === "longpress") {
this._tableViewSection && this._tableViewSection._tableView && (this._tableViewSection._tableView._tableViewRowClicked = this);
}
View.prototype._handleTouchEvent.apply(this,arguments);
Expand Down
11 changes: 7 additions & 4 deletions mobileweb/titanium/Ti/UI/TableViewSection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
define(["Ti/_/declare", "Ti/_/lang", "Ti/_/UI/Widget", "Ti/_/style","Ti/UI/MobileWeb/TableViewSeparatorStyle", "Ti/UI"],
function(declare, lang, Widget, style, TableViewSeparatorStyle, UI) {

var is = require.is,
var on = require.on,
emptyfn = function(){},
is = require.is,
setStyle = style.set;

return declare("Ti.UI.TableViewSection", Widget, {
Expand All @@ -24,16 +26,17 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/UI/Widget", "Ti/_/style","Ti/UI/Mobil
// Create the parts out of Ti controls so we can make use of the layout system
this.layout = UI._LAYOUT_CONSTRAINING_VERTICAL;

// Force single tap to be processed.
this.addEventListener("singletap");
// Force single tap and long press to be enabled.
on(this, "singletap", emptyfn);
on(this, "longpress", emptyfn);
},

_defaultWidth: UI.INHERIT,

_defaultHeight: UI.SIZE,

_handleTouchEvent: function(type, e) {
if (type === "click" || type === "singletap") {
if (type === "click" || type === "singletap" || type === "longpress") {
this._tableView && (this._tableView._tableViewSectionClicked = this);
}
Widget.prototype._handleTouchEvent.apply(this,arguments);
Expand Down

0 comments on commit 0292ebd

Please sign in to comment.