View Full Version : suspendEvents on a Button doesn't prevent tapcancel or tapstart

17 Aug 2011, 11:58 AM
Sencha Touch version tested:



Using suspendEvents() on a Button doesn't prevent onTapCancel or onTapStart from being called.
There is an undocumented property called preventCancel but it is only checked if the cancel occurs in the onPress function called by the tap listener. onTapCancel and onTapStart handle adding and removing the pressed css class and as a result added to the amount of code needed to have the button behave like a toggle.

Steps to reproduce the problem:

create a button
add it to a container
call suspendEvents() on the button
tap and slide your finger off the button

The result that was expected:

expected events to not fire

The result that occurs instead:

tapcancel and tapstart still fire

Debugging already done:

suspendEvents only has an effect if fireEvent is called, which doesn't effect tapcancel and tapstart on the button.

Possible fix:

suspendEvents sets a property called eventsSuspended to true, onTapCancel and onTapStart should check this property.

For now the way I'm using the button allows me to clear the listeners and have that be an acceptable solution since the button will never need to work again any time in its lifespan. But if I my use case required that the button be able to be made active again it would have been a bigger headache than it is.