Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-9894] LongPress support in table view. #2512

Merged
merged 2 commits into from
Jul 6, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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