Skip to content

Commit

Permalink
Merge pull request #5446 from hieupham007/timob-16449
Browse files Browse the repository at this point in the history
timob-16449: Fix touchEnabled functionalities, deprecate enabled.
  • Loading branch information
srahim committed Mar 11, 2014
2 parents 0c0a7cc + 6c9b84d commit 9629286
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
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

0 comments on commit 9629286

Please sign in to comment.