Modernized code which supports now also gesture events.

It works automatically for gesture events as it worked for touch events.