[TIMOB-11866] iOS: Click event in UIView is firing immediately
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-12-06T01:25:08.000+0000 |
Affected Version/s | Release 2.1.2, Release 2.1.3, Release 2.1.4, Release 3.0.0 |
Fix Version/s | Release 3.0.1, Release 3.1.0, 2012 Sprint 25, 2012 Sprint 25 API |
Components | iOS |
Labels | api, module_views, qe-testadded, triage |
Reporter | Rafael Kellermann Streit |
Assignee | Vishal Duggal |
Created | 2012-10-11T20:42:15.000+0000 |
Updated | 2013-01-15T15:36:00.000+0000 |
Description
*Actual result*
UIView 'click' event is fired instantly when the user puts their finger inside the UIView.
*Expected result*
The event should only be fired when click is completed.
Examples:
*ImageView*
var window = Ti.UI.createWindow({
backgroundColor : 'white'
});
var image = Ti.UI.createImageView({
image : "KS_nav_ui.png"
});
image.addEventListener("click", function() {
alert("I didn't removed my finger from touch yet!");
});
window.add(image);
window.open();
*View*
var window = Ti.UI.createWindow({
backgroundColor : 'white'
});
var view = Ti.UI.createView({
width : 100,
height : 100,
backgroundColor : "#FF0000"
});
view.addEventListener("click", function() {
alert("It happens here too.")
});
window.add(view);
window.open();
Needs more info - what Titanium Mobile SDK? What iOS version?
Hello Daniel, I think it happens since first SDK. But I'm using SDK 2.1.3.GA and iOS 6. Thanks!
Is it possible to provide a copy + paste reproduction case that doesn't involve an image view? Or does it only happen with image views?
I think the problem is in all components based in UIView. For example:
Probably the event *click* is inherited from UIView delegate, so, it happens to all components based in UIView. Thanks
Here is the code that produces it: **TiUIView.m** LINE: 1033 - Titanium SDK 2.1.3.GA
You can see, that *processTouchesBegan* is firing *click* event.
Is there any update? I really think that it needs to be resolved in 3.0 SDK.
Tested and confirmed iOS 5.1, TISDK 2.1.2 GA, 2.1.3 GA, 2.1.4 GA, 3.0.0 CI.
Pull pending https://github.com/appcelerator/titanium_mobile/pull/3524
Backport PR to 3_0_X https://github.com/appcelerator/titanium_mobile/pull/3637
Verified with following Titanium SDK: 3.1.0.v20130102102603 Titanium SDK:3.0.1.v20121228113204 Titanium Studio:3.0.1.201212181159 Device: Simulator iOS 6.0
As of SDK 3.1.0.20130109175536, there's a side effect of this fix: if a slow click is performed (where the click lasts longer than half a second), the click event doesn't fire at all. I'm doing this with the mouse in the simulator, so there is no movement during the click. Is this intentional?
@Shawn Lipscomb - I believe that is a intended behavior change. If you click for more than half a second then it no longer is a click event , it becomes a long press instead.
I agree with Sabil. If you wanna handle a long press, you should use the longpress event. BTW, we could verify if UIView have some listener for *longpress*. If not have, we can fire event to click handler. What do you think? It probably will reduce some bugs in currently applications (and future).