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-16449: Fix touchEnabled functionalities, deprecate enabled. #5446

Merged
merged 1 commit into from
Mar 11, 2014
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
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
} else if (key.equals(TiC.PROPERTY_FOCUSABLE) && newValue != null) {
registerForKeyPress(nativeView, TiConvert.toBoolean(newValue, false));
} else if (key.equals(TiC.PROPERTY_TOUCH_ENABLED)) {
nativeView.setEnabled(TiConvert.toBoolean(newValue));
doSetClickable(TiConvert.toBoolean(newValue));
} else if (key.equals(TiC.PROPERTY_VISIBLE)) {
newValue = (newValue == null) ? false : newValue;
Expand Down Expand Up @@ -1458,25 +1459,25 @@ protected void registerForTouch(final View touchable)
return;
}

boolean clickable = true;
if (proxy.hasProperty(TiC.PROPERTY_TOUCH_ENABLED)) {
clickable = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_TOUCH_ENABLED), true);
boolean enabled = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_TOUCH_ENABLED), true);
if (!enabled) {
touchable.setEnabled(false);
}
}
registerTouchEvents(touchable);

if (clickable) {
registerTouchEvents(touchable);
// Previously, we used the single tap handling above to fire our click event. It doesn't
// work: a single tap is not the same as a click. A click can be held for a while before
// lifting the finger; a single-tap is only generated from a quick tap (which will also cause
// a click.) We wanted to do it in single-tap handling presumably because the singletap
// listener gets a MotionEvent, which gives us the information we want to provide to our
// users in our click event, whereas Android's standard OnClickListener does _not_ contain
// that info. However, an "up" seems to always occur before the click listener gets invoked,
// so we store the last up event's x,y coordinates (see onTouch above) and use them here.
// Note: AdapterView throws an exception if you try to put a click listener on it.
doSetClickable(touchable);

// Previously, we used the single tap handling above to fire our click event. It doesn't
// work: a single tap is not the same as a click. A click can be held for a while before
// lifting the finger; a single-tap is only generated from a quick tap (which will also cause
// a click.) We wanted to do it in single-tap handling presumably because the singletap
// listener gets a MotionEvent, which gives us the information we want to provide to our
// users in our click event, whereas Android's standard OnClickListener does _not_ contain
// that info. However, an "up" seems to always occur before the click listener gets invoked,
// so we store the last up event's x,y coordinates (see onTouch above) and use them here.
// Note: AdapterView throws an exception if you try to put a click listener on it.
doSetClickable(touchable);
}
}


Expand Down
3 changes: 3 additions & 0 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,9 @@ properties:
description: Set to `true` to enable or `false` to disable the view.
default: Enabled by default. (Property value may be undefined.)
type: Boolean
deprecated:
since: "3.3.0"
notes: This is deprecated on Android. Use [touchEnabled](Titanium.UI.View.enabled) property instead.
platforms: [android, blackberry]

- name: focusable
Expand Down