Skip to content

Commit

Permalink
[#951 state:fixed-in-qa][#1931 state:fixed-in-qa][#1934 state:fixed-i…
Browse files Browse the repository at this point in the history
…n-qa][#1937 state:fixed-in-qa][#1939 state:fixed-in-qa][#1940 state:fixed-in-qa] Fixing regression where keying off of presence of 'click' handler broke the expectation that views are touchable by default. Added support for touchEnabled. If touchEnabled is false, click proceeds through all views until one that handles click and is located under the touch point is found. Several of these defects were side-effects attributable to clickability.
  • Loading branch information
donthorp committed Sep 29, 2010
1 parent d9f1b41 commit d074f62
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Expand Up @@ -177,7 +177,9 @@ else if (props.containsKey("hasCheck")) {
if (rp.getDynamicValue("title") != null) {
title = TiConvert.toString(rp.getDynamicValue("title"));
}

if (!rp.hasDynamicValue("touchEnabled")) {
rp.internalSetDynamicValue("touchEnabled", false, false);
}
if (views == null) {
views = new TiUIView[1];
views[0] = new TiUILabel(rp);
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.appcelerator.titanium.util.Log;
import org.appcelerator.titanium.util.TiAnimationBuilder;
import org.appcelerator.titanium.util.TiConfig;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.TiAnimation;
import org.appcelerator.titanium.view.TiUIView;

Expand Down Expand Up @@ -564,7 +565,9 @@ public void eventListenerAdded(String eventName, int count, TiProxy proxy) {
super.eventListenerAdded(eventName, count, proxy);

if (eventName.equals("click") && proxy.equals(this) && count == 1 && !(proxy instanceof TiWindowProxy)) {
setClickable(true);
if (!proxy.hasDynamicValue("touchEnabled") || TiConvert.toBoolean(proxy.getDynamicValue("touchEnabled"))) {
setClickable(true);
}
}
}

Expand All @@ -573,7 +576,9 @@ public void eventListenerRemoved(String eventName, int count, TiProxy proxy) {
super.eventListenerRemoved(eventName, count, proxy);

if (eventName.equals("click") && count == 0 && proxy.equals(this) && !(proxy instanceof TiWindowProxy)) {
setClickable(false);
if (proxy.hasDynamicValue("touchEnabled") && !TiConvert.toBoolean(proxy.getDynamicValue("touchEnabled"))) {
setClickable(false);
}
}
}

Expand Down
Expand Up @@ -123,7 +123,11 @@ protected void setNativeView(View view) {
view.setId(idGenerator.incrementAndGet());
}
this.nativeView = view;
nativeView.setClickable(proxy.hasListeners("click"));
boolean clickable = true;
if (proxy.hasDynamicValue("touchEnabled")) {
clickable = TiConvert.toBoolean(proxy.getDynamicValue("touchEnabled"));
}
nativeView.setClickable(clickable);
nativeView.setOnFocusChangeListener(this);
}
protected void setLayoutParams(LayoutParams layoutParams) {
Expand Down Expand Up @@ -265,13 +269,15 @@ public void propertyChanged(String key, Object oldValue, Object newValue, TiProx
nativeView.requestLayout();
}
} else if (key.equals("focusable")) {
boolean focusable = TiConvert.toBoolean(newValue);
boolean focusable = TiConvert.toBoolean(proxy.getDynamicValue("focusable"));
nativeView.setFocusable(focusable);
if (focusable) {
registerForKeyClick(nativeView);
} else {
nativeView.setOnClickListener(null);
}
} else if (key.equals("touchEnabled")) {
nativeView.setClickable(TiConvert.toBoolean(newValue));
} else if (key.equals("visible")) {
nativeView.setVisibility(TiConvert.toBoolean(newValue) ? View.VISIBLE : View.INVISIBLE);
} else if (key.equals("enabled")) {
Expand Down

0 comments on commit d074f62

Please sign in to comment.