javascripttitanium

Onclick Events in Titanium Require Waiting Several Seconds Between Clicks


I've got a mobile app written using Titanium SDK. There are various views that have click events. Some are assigned through the XML view using onClick="functionName", and others are assigned using $.viewId.addEventListener('click', function(){}).

Either way, if I click on a view once, I have to wait for anywhere from five to forty five seconds before it will allow me to click on it to perform the function again. This is for all of the pages that use native views.

Clicking on a second different view works just fine, the first time. It's only when I click the same view a second time that I notice the delay.

The pages that use WebViews do not have this problem. So native Titanium is less responsive than WebViews with HTML and JavaScript.

This problem is present for both 12.1.0.RC and 12.2.1.GA.

Is this an intentional feature or a know bug in Titanium SDK?

How can I make the click events work for a second click more rapidly?


Solution

  • Click events:

    XML and JS event listener do the same thing. If you assign it in the XML/Alloy it will automatically add the addEventListener and removeEventListener for you. So it takes less code to write the listeners. You can see that in the generated code in Resources/android/alloy/controllers/

    Delay:

    The phone has a "delay" to differentiate between tap, click, double click and so on. But there shouldn't be any delay in the SDK itself. What you can do if you need a faster click rate: use the singletap event (https://titaniumsdk.com/api/titanium/ui/view.html#events_singletap) instead of click.

    A webview doesn't use native elements so the phone rules don't apply there. That's why a click is different in a webview.