var win = Ti.UI.createWindow({
backgroundColor:'green',
width:'100%',
height:'100%',
// fullscreen : true,
// navBarHidden : true
});
var view = Ti.UI.createView({
width:'20%',
height:'20%',
backgroundColor:'red'
});
view.addEventListener('touchstart',function(){
view.backgroundColor = 'white'
});
view.addEventListener('touchend',function(){
view.backgroundColor = 'red'
});
win.add(view);
win.open();
step 1 : Run the above code
step 2 : tap on the red view
step 3 : without removing the finger tap on the green window or in the white view again
step 4: remove both fingers
Actual result
The view remains white
expected result
The view should turn red
1. It also reproduces on 3.1.3RC 2. Here's another way to cause the bug: tap inside the view to trigger touchstart, then tap quickly outside the view (even if you do lift the finger, doesn't matter) - the touchend doesn't fire. 3. The same bug occurs even without event listeners - just define backgroundColor and backgroundSelectedColor, and on occasion the backgroundSelectedColor is stuck. 4. This bug is extremely annoying! On small clickable elements, when the user is apt to often click on the element boundary, it appears to happen quite a lot in normal usage patterns.
Also happens with backgroundSelectedImage. Frankly I'm surprised this is pushed out to 3.2.0 - it's a pretty serious issue, giving the user wrong indications regarding key events such as button clicks.
[~mokesmokes] I agree it needs to be fixed, but we can only take on so many issues at once. We always welcome pull requests against titanium_mobile to help speed up the process.
Ingo, I hear you loud and clear..... and with iOS7 release you guys have more than a handful. However, for Android this is a big UI issue, I'm hoping it can be fixed and merged into 3.1.x even if not in an official release. I'm in complete agreement on the PRs, I have submitted several already, not sure though that I will be able to dig into this one soon. Thanks!
OK - here's the source of the bug: the touch listener in TiUIView.java gets confused when there are secondary touches after the initial touch start. Here is the simplest example I logged: 0 (ACTION_DOWN), 261 (ACTION_POINTER_2_DOWN), 6 (ACTION_POINTER_1_UP), 1 (ACTION_UP) touchstart is fired after ACTION_DOWN, touchend is never fired and of course the backgroundSelectedColor/Image is stuck. Frankly, I don't understand the implemented logic with the secondary touches in this function, but somehow you're losing the end event. It would be great if someone familiar with this code took care of this, since accidental, secondary touches happen frequently, and the UI just goes bonkers with this bug. Thanks!
Additionally, the logic in that function also triggers the 'twofingertap' event on the view - even though only one of the touches was inside the view....
(Attempted workaround deleted)
Pull request submitted: https://github.com/appcelerator/titanium_mobile/pull/4720 Description: In Android there are frequent cases when the touchend event is not sent, when the background colors and images are not responding correctly to touches, etc. The root of this issue is the additional handling for (the rarely used) pinch and twofingertap events. (BTW - in the docs pinch is defined for iOS only..... but the Android code apparently supports it, untested by me). This PR skips the handling for pinch and twofingertap if there are no listeners or these events, and thus restoring correct behavior for the rest of the touch events. Item of note: it's not clear how twofingertap is supposed to interact with backgroundSelectedColor/Image, and touchend (all these seem to not function with twofingertap, both before and after this PR).
Does this really need to be pushed out to 3.3.0? The PR I submitted works and is in production in my app, for about a month now without a glitch. Touches were much less reliable before my fix.
I'll try and pull it back. We're just way overloaded.
Another test case for the "twofingertap" event. For FR, run the code, and touch the screen with one finger inside the red view and on finger inside the green view. It should not fire "twofingertap" event.
Hi [~mokesmokes], I left comment on your PR. Due to the tight schedule for the release, can you take a look and let me know if you have time to update it ASAP? Thanks.
Hi, I also commented on the PR. Unfortunately I don't have time to make additional updates on the PR. Having said that, if your team doesn't have the time either - my PR is definitely better than the existing situation, where simple click handlers, background image changes, etc don't work as expected in many cases.
PR: https://github.com/appcelerator/titanium_mobile/pull/4917 For FR, please run the above two test cases, and TIMOB-768 and KS->BASE UI->Window Events.
CR + FR
Touchend event is getting fired when two touches occurred. Using Environment: Appcelerator Studio, build: 3.2.0.201311112306 SDK:3.2.0.v20131111174605 alloy: 1.3.0 CLI : 3.2.0 Xcode:5.0.1 Device: Google nexus 7(v4.3),Samsung Note(v2.3.6) OS: Mac OSX 10.9